Perl6 rakodu on Mac OS X version 10.7.3


  1. download rakudo perl6 src from git
    https://github.com/downloads/rakudo/star/rakudo-star-2012.04.tar.gz

  2. perl Configure.pl –prefix=<DIR> –gen-nqp –gen-parrot

    <DIR> directory where you want to push the binaries of perl6
    It will avoid clash with existing Perl version running in system
    After command executed successfully check prefix dir, it should show following dir’s
    drwxr-xr-x 3 root staff 102 Apr 29 23:06 share
    drwxr-xr-x 3 root staff 102 Apr 29 23:06 include
    drwxr-xr-x 6 root staff 204 Apr 29 23:06 lib
    drwxr-xr-x 3 root staff 102 Apr 29 23:06 src
    drwxr-xr-x 14 root staff 476 Apr 29 23:08 bin

  3. make
  4. make rakudo-testAll tests successful.
    Files=23, Tests=227, 15 wallclock secs ( 0.09 usr  0.06 sys + 11.54 cusr  2.86 csys = 14.55 CPU)
    Result: PASS
  5. make rakudo-spectest
  6. make install

Ruby Rocks :)


Today I am going to share my very first experience with RubyOnRails, and to describe my feelings its fabulous.

Lets begin

What you need to know already?

  • You should be familiar with any MVC pattern
  • Should have knowledge of Ruby
  • Should know DB & Web server fundamentals

I guess thats more then enough to begin rails journey.

To start with you need following software installed on your box, 🙂 I ma LILO fan so all below configuration and are Linux based. But based on this understanding one can quickly start writing on any other OS too.

Software Needed

  • ruby 1.8.4
  • rails 1.2.3

Once installation and configuration done

rails test_app

cd test_app

vi config/database.ym

add your db credential

script/generate migration add_formelements

> create db/migrate
> create db/migrate/001_add_formelements.rb

vim db/migrate/001_add_formelements.rb

Add code
class AddUsers < ActiveRecord::Migration
def self.up
create_table “formelements” do |t|
t.column “user”, :string
t.column “email”, :string
t.column “password”, :string
t.column “passordreminder”, :text
end
end

def self.down
drop_table “
formelements
end
end

rake db:migrate

== AddUsers: migrating ========================================================
— create_table(“formelements”)
-> 0.0234s
== AddUsers: migrated (0.0236s) ===============================================

script/generate scaffold Formelement

exists app/controllers/
exists app/helpers/
exists app/views/formelements
create app/views/layouts/
create test/functional/
dependency model
create app/models/
create test/unit/
create test/fixtures/
create app/models/formelement.rb
create test/unit/formelement_test.rb
create test/fixtures/formelement.yml
identical app/views/formelements/_form.rhtml
create app/views/formelements/list.rhtml
create app/views/formelements/show.rhtml
create app/views/formelements/new.rhtml
create app/views/formelements/edit.rhtml
create app/controllers/formelements_controller.rb
create test/functional/formelements_controller_test.rb
create app/helpers/formelements_helper.rb
create app/views/layouts/formelements.rhtml
create public/stylesheets/scaffold.css

script/server

http://yourserver3000/skills

That’s all enjoy!

Hope you have grate time doing above exercise.

Check this out http://tryruby.hobix.com/

JAVA Design Pattern


JAVA Design Pattern

The design patten is a vast subject, I will be giving you an head start here

Gang of Four – widely used design patterns

  1. Behavioral patterns
    1. Chain of responsibility
    2. Command
    3. Interpreter
    4. Iterator
    5. Mediator
    6. Memento
    7. Observer
    8. State
    9. Strategy
    10. Template method
    11. Visitor
  2. Creational patterns
    1. Abstract factory
    2. Builder
    3. Factory method
    4. Prototype
    5. Singleton
  3. Structural patterns
    1. Adapter
    2. Bridge
    3. Composite
    4. Decorator
    5. Facade
    6. Flyweight
    7. Proxy

Definition:- Common Problem and Common Solution for them, If you have data with problem and to tackle that you need to find problem pattern and propose solution pattern for that.

Note: No body owns the design pattern

Standard pattern are 23 those are listed above.

J2EE design pattern standardize by sun

EJB Patterns

  1. Intercepting Filter (apache mod rewrite)
  2. Composite View
  3. Front Controller
  4. Service to worker
  5. Business delegate
  6. Service Locater
  7. Transfer object assembler
  8. Facade

site: theserverside.com
site:www.tml.tkk.fi/~pnr/GoF-models/html

EJB cont


Entity Bean

An entity bean is representation of single row in a databases. Entity always be an heavy component. But the connectivity to database will be a transparent to developer. When you create a new entity bean automatically in database new row will be added.

ORM – Object Relational Mapping, row in a table will be one object in memory.

Stateless Session Bean can have pooled creation.

Statefull Session Bean can have cached creation.

But Entity bean can have either cache or pooled creation.

Whenever you need to work with processed or in other words process matters over data you should use session bean. But whenever you want to work with DATA or in other words DATA matters over process you should use entity beans.

Entity beans are heavy object because its a in memory object for database table. Where each instance of entity bean object refer to one record set in table or row in table.

Entity beans are of two types
Bean Managed Persistence
Container Managed Persistence

CMP Bean
Local Client
Remote Client

Favourite topic WSAD entity bean example 🙂 without writing a single line of code get the entity bean in place here we go

  1. Create new project EntityBean
  2. Create new Enterprise bean
  3. Select Type Entity bean
  4. Select CMP bean 2.0
  5. Bean detail select Remote & Local both the interfaces
  6. Select the project
  7. Run the Entity bean on server
  8. Configure new Test Server or run on existing server
  9. Create table and deploy entity bean
  10. Finish
  11. It will show success message, i.e. it will test the create and alter statement on newly created table.
  12. Select server client local
  13. Finish
  14. It will open Test Client
  15. Click on EntityExampleLocal
  16. Click on CMPLocal.findByPrimaryKey
  17. Enter value into and click invoke.

This how you will be testing tyour entity beans. Just now what we have seen is the Top to Bottom appoch, we have another approach which is Bottom to Top where in we will be having table already existing in and then will be creating the entity bean accordingly.  

Facts……….

-EJB can be accessed using servlet
-Entity Bean should not be remote
-Session Bean should not be local
-In entity bean you should not use primitive data-type.

ENTERPRISE JAVA BEANS


sCOPE oRGANIZATION wIDE

MVC
Model= EJB
View= JSP
Controller = SERVLET

Why should we go for EJB?
Scalability (application should work same for 2 client and 2 million client.)
Should be catering to multiple request simulatanously.
Problem with the thread is Sycronization.
EJB CONTANER, will work on instance pooling and multiple instance.

Example
jdbc

to enable tansaction, first step is to make the autocomit off.
set autocommit flase applicable to the JVM where this property is set.

focus should be buisness logic, let transaction manage by somebody so this will be managed by CTM (container transaction management)

Web server & application server
Diffrence
Application server is super set of web server. In other words web server can be one component in application server.
Main diffrence will be application server is aware of its surroundings.

  1. Security
  2. Application control
  3. Infrastructural Capability

Application Server Main Properties

  1. Transaction management
  2. LDAP
  3. Persistance
  4. Threading
  5. Socket
  6. DBMS

Enterprise Level Application
EJB can be deploy only on Application Server. Used for scalable problems.

MESSAGE BEANS: asyncronous communication

If you need to generalizes something you make implementation and every one will write interface for it.

EJB distributed component need security any request comes in from cinet has to be checked.

EJB Contaner will decide whether to provide you access or not.

Per bean there will be one instance object.
Rule of thumb: One client one bean one instance will be always true.

Types of Bean

  1. Session Bean
    1. Stateless bean
    2. Statefull bean
  2. Enttyty Bean
    1. CMP – Container Managed Persistence
    2. BMP – Bean Managed Persistence
  3. Message Driven Bean (MBD) – Asyncronous beans

what to used and when to use

Session
Dealing with process, Its a temporary or volatile.

Stateless-Session bean without any instance variables. i.e. processed are not dependent on each other. Example could be Controlling Mechenism

Statefull-Session bean with instance variable i.e.

Entity
Dealing with DBMS or Data

EJB FrameworkEJB framework Session Facade (Mean entry point.)

Creating session bean from Web Sphear Application Development.

EJB Module -> Project -> EJB -> Create 2.0 EJB -> Project Name -> Module Deps -> Finish

  1. newInstance()
  2. ejbCreate
  3. setSessionContext

Technology

Reflection & Retropection
Runtime can find out class and charachterstics

Terminology
Call back method
Calles when an event occurs.

Thoughts on java

Java in not 100% OO?
1) Static classes, does not require instance to acces its charachterstics.
2) Reperesantation of real world entity without charachterstic is not possible. But we can create java class without any class variables.

Import Definations

Abstraction
Real world entity properties create class.

Coupling and Cohesion Software Engineering.