Monday, March 21, 2011

Spring king of all season

Most of the developer worked in Java is aware of spring frame work. And who doesn't know anything about Spring framework can think about experienced spring season. Like many other frame works available Spring also serve as container. It creates the java object/component run time and manage them. The application developer can concentrate on business logic and really forget about managing objects. When people talk about Spring two terms dependency injection and inversion of controller always comes. Let me also write about these... When there is a situation a object use another object (association).
Lets have an example:
Class Orchestra                  
{
     Dancer  dancer = new Dancer();
     Singer   singer = new Singer();
     perform()
       {
           dancer.dance();
           singer.sing();
       }
}

Here Orchestra class use Dancer and Singer to perform the job.  Well tomorrow we need some modern dancing and some different kind of Song we have to change the Orchestra class.
In Spring way we can re write some thing like below.

Class Orchestra                   
{
     IDancer  dancer;
     ISinger   singer;
     perform()
       {
           dancer.dance();
       singer.sing();
       }
}

Interface IDancer
{
   dance();
}

Interface ISinger
{
   sing();
}

BreakDancer implements IDancer
{
  dance()
   {
     ----
     ----
   }
}
RockSinger implements ISinger
{
  sing()
   {
     ----
     ----
   }
}

In Runtime we can inject the dancer and Singer to Orchestra using Spring. Well here with singer and dancer we are injecting the dependency to Orchestra. And Orchestra gave the control which kind of dancer and singer is going to perform. This is something called inversion of control.  We can do both xml based or annotation based configuration in Spring. Here is the xml version
<bean id="orchestra" class="com.action.Orchestra">
     <property name="singer"><ref bean="rockSinger"/></property>
    <property name="dancer"><ref bean="breakDancer"/></property>
</bean>
<bean id="rockSinger">
    <property name="target">
            <bean class="com.action.RockSinger" />
        </property>
</bean>
<bean id="breakDancer">
    <property name="target">
            <bean class="com.action.BreakDancer" />
        </property>
</bean>         


So spring gives such a environment where  we have all the freedom to configure anything up to any level.
Have a nice time in Spring :)

Thursday, March 10, 2011

Don't Own.Rent and Use



Its always a trade off whether to own or take it on rent. Like some time its very difficult to buy a luxury house but you can take it for rent. Actually its not applicable to only house we can extend it to car, furniture even girl friend also :p The advantage of taking on rent is as we don't own it we only pay as we use. The trend is slowly moving towards pay for usage of software also. For example to write this blog i don't have to own a blogging site, I can use google service with all other users. Certainly I can customize it . I agree i cant customize it to the extend if i own it. But it is really economical. Well the idea can be roll into all possible s/w. Lets think a scenario when the SAP will host all its enterprise solution in its server and all the company will use through web. Well it has challenge like security, customization according to user ... But i feel the industry is mature enough and ready to take this challenges. Infact TCS is already started with iON for small scale and mid scale industry.It reduces the software cost dramatically and can be accessible to lots. People say it software as service, software on cloud....Its just renting software... So before all the big player enter to the game lets rent some thing :P

Wednesday, March 2, 2011

Designing is a Luxury

It was a hot summer, I had joined a new team we all were working towards a new project. To understand the system and to arrive common understanding we were doing prototype and series of discussions with end users. I had a chance to part of design team. In that phase we had a review with our delivery manger. We updated the status like now we are designing the system and the status of the progress. The manager told "Well you have a luxury to design. Have fun." I thought whats the fuck design is essential and I read in all s/w life cycle book there is a design phase. Any way I forgot that statement as my brain was not able to process that statement further.
Then I tried to learn basic design concept, design pattern, Gang of 4 everything I found in internet. Somebody told me no need to reinvent the wheel use the existing solution available in pattern. My problem was to fit a pattern according to my requirement. Well some how I copied from existing design with little modification finished the design before dead line. We had a fantastic feed back in the review meeting. Then we kept it as a monument which we never use.

Its very obvious that developers needs freedom to write their implementation. If I want my design to be implemented its really important developer should understand. We can broadly say 2 things while doing/thinking about a design.
1) If tomorrow there is a change in business rule or a new feature is added, whether it can be plugged easily with out rebuilding the existing classes.
2) How I am going to communicate my idea to the developer, so that developer really can follow it
Still Thinking ....