Friday, December 16, 2011

Annotation in Java, the last moment of information


In any football match you will find the coach jumping, screaming telling something to the players. Its not only in football even in Cricket and other sports the coach will try to give some more information to the players on field.Though there was a detail game plan which involve coach, captain and all players much before the match. They know what to do everything is planned, still the coach has to say "one more thing" while the game is in progress.
Same case with us developer, we used to think and  design our codes then write. Still we want to add some more thing while compiling or execution time. I always wish I can say the compiler hey just suppress the warning go ahead compile it, while execution of program we have always want to say something to it about the environment. Well in Java we got some thing called Annotation which serve this purpose.
Annotation can be used to give additional information about a class,method or member to compiler or JVM.
Lets look at some example.
I want to write a class which represent an table in database. We say this kind of of object as Entity object.

@Entity @Table (name = "tbl_employee") 
public class Employee{
   @Id private Long employeeId;
   ...
   private Address address;
   @Clob public Address getAddress() { return address; }
   public void setAddress() { this.address = address; }
}

Here we say Employee is an entity class. It mapped to tbl_employee in database, employeeId is a primary key and getAddress return Clob.
These information is very essential for a ORM framework like JPA or Hibernate.

we use annotation to tune compiler also.

@SuppressWarnings(value = "unchecked")
void myMethod() { }



We use similarly for for run-time  to give more information to JVM. Like everything Java has some inbuilt annotation and user defined also. How to define a custom annotation and where it make sense is another topic. I will write it separately. Mean while you can look for more information here.

Saturday, November 19, 2011

Which language do you speak ?? "Vlingo" !!


Hi to one and All,

After Friday comes Saturday. Surely you people remember "Friday", ain't it ?? (Nope,nope,nope I am not talking about the famous "Friday" from Daniel Defoe master piece "Robinson Crusoe"..rather this one http://java-pallab.blogspot.com/2011/10/lets-talk-about-friday.html). Well, till now I haven't got an invitation for this, but still the wait is on.


Meanwhile, moving on, it took me a while to get used to IRIS (tiny sister of SIRI, but no way nearer to it). I was looking for something in Android, which is more advanced  and could do at least the basic stuff that SIRI can do, sending text, calling people through voice, do some basic search. Although IRIS has improved a lot from its initial stages, it didn't satisfy my taste as a new android smart phone user. I just couldn't resist the idea of interacting with my phone verbally in a language I know. And soon enough my inquisition led me to my old Guru, who can answer virtually everything; Google. And one day after coming back from office, i started searching in Android market. I didn't have to wait for long. In next 5 mins I just discovered "Vlingo". And you know what my first thoughts were, Is it free Or a paid app. 


To my utter relief, I found it to be free and the next thing I could remember was calling out one of my friends name at the top of my voice, so that my phone can listen to me and make a call to him. And to my amazement, it somehow understood my Indian ascent and called up my friend. And after that I posted a comment on Facebook, I opened twitter, I messaged to two of my friends and even found out the nearest ATM machine around my place in a 6 mins of frenzied usage of "Vlingo". And to my satisfaction everything worked.


This was much better than IRIS and there are a lot of options, more than what I expected. I was happy because, first thing, it understood what I said ( You can very well infer that from the title). And second thing, it has a wonderful GUI, I somehow liked the color and look and feel and third thing it has an iVersion i.e. you have an app for iPhone also unlike SIRI. For more information you can have a look at the video http://www.howcast.com/videos/258569-How-To-Do-Things-Faster-With-Your-Mobile-Phone-Using-Vlingo.


I would be exploring it more to check out its some more interesting features...Till then 


This is Bishnu.....Signing Off..

Wednesday, November 9, 2011

"Interface" The Middle Man

We will always find middle man in between producer and consumer of anything. Sometimes more than one layer of middle man. Both producer and end user hate those middle man. They just rip profit by somehow involving in transaction. But no one will deny it require lots of thinking to establish a model which doesn't need middle man. Let’s understand what kind of value these middle men bring.
Like real world every software or services is integration of various modules. Each module is responsible to carry out certain task. Some component consumes the output of other; to integrate these we need middle man. In Java we say it “Interface”.  The basic idea of interface is to act like middle man. But in Java world it can do some additional things.
1)     As the name suggest Interface is basically to integrate two different components.  It exposes the functionality of one component to other in a simple manner.
2)     It can be used to hold Constants of the project. As the properties of Interface are always public and final.
3)     Java doesn’t allow multiple inheritance. So One class can’t extend multiple classes, the work around in Interface. One class can implement multiple interfaces. And a reference of an Interface can hold the Object of implementing class. 
Class A implements Ia {}
Ia ia = new A();
In this way it gives lots of option to designer.
4)     Interface enforces certain behavior on the class. For ex: if my object is instance of Serializable, then the object can be persisted. Interface is used to mark the Object.
5)     I found the best use of interface is it helps to design lots of generic stuffs. It helps in reducing tight coupling between component.
Please share your thoughts and experience with Interface in programming and real life as well.


Monday, October 24, 2011

Let's Talk About FRIDAY

Hi All,

We are now living in a fast growing world. Everyday gives us something new to wonder about and new to think about. And the first thought comes to my mind, what next. And everyday i again start with the same thought...WHAT NEXT....

When the other day i was sitting and having a coffee at a wee hour in office, one of my colleague pointed out that the biggest shock our time has also given birth to probably one of the finest inventions of our time. Used to seeing these technologies in movies like MI and all the Bond movies suddenly this became a beautiful reality of our times. Those who are wondering what i am talking about, yes it is Steve Jobs and SIRI respectively.

Everyone appreciated it and hailed Steve Jobs for this wonderful innovation. But now allow me to go back to that wee hour in office, where my colleague also told me (although rather vaguely) about IRIS. Yes, looking at those bold letters you can find out that this is SIRI in reverse. That is exactly what you find in the app overview in the Android Market. I went and downloaded the app then and there. It was interesting, nothing like SIRI, but still interesting. And the mother of all surprises, it was developed by a small group of individuals in Kochi lead by Narayan Babu after a marathon 8 hour long stretched adrenaline rush (http://blog.dexetra.com/a-day-when-siri-inspired-us-to-create-iris-fo). I rest my case here to the further analysis of my readers about how successful IRIS would be.

But I am not going to bash SIRI nor am I going to praise the team for evolving IRIS. Rather I would like to draw all of your attention to something very interesting that they were developing. Of course the development of IRIS gave them a good exposure to the world, but it simply doesn't make their innovation any less spectacular.

So let's talk about FRIDAY. No no no....not the weekend (It is certainly not a weekend but we always make it one.Gone are the days when Sunday used to be the only weekend...rather the term weekend was non-existent. Anyway, let's focus on the topic). That is what these guys were developing for almost a year now. Before I confuse you with all my explanations, just have a look at the video to see what it is(http://www.youtube.com/watch?v=6vTqYgcKJZ0&feature=player_embedded). Doesn't need much more explaining...does it ?

The interesting thing is, this can tell you where you were, when your battery died last time or for that matter when you were talking to your girlfriend :P (Atrocious logic...why would someone like to know that....But you never know). And you know what, you can register for the Hangout in Google+ for this and check out the launch of friday-app. At least Google+ will have some more hits.

Check this out...And I will let you know about the features...till then....

This is Bishnu Signing Off.....

Saturday, October 15, 2011

iPhone 4S



After launch of iPhone 4s it disappoints many people who are expecting lots form it. It was a very important event as it took Apple long 13 months and there was no Steve Jobs this time. It’s the first iPhone launched with Out Steve Jobs taking stage. So there were lot of buzz and comparison of Tim Cook’s show with Steve Jobs. 
People expectation from Apple CEO on stage is very high, probably no other company’s product launch can match. There were lots of speculation that next version iPhone will all new design some thing like thinner, big screen etc.
Lets understand the realities, it is certainly very clear no body can step into Steve Jobs shoe. And unfortunately Steve Job can’t take stage anymore due to law of nature. 
And coming to new design, Apple can’t just change the design with each new version. If design change adds significant values then it makes sense. Design change also involves change in manufacturing process. And iPhone 4 is still the sexiest phone available  with respect to design.
With iPhone 4s it catch up with some linear hard ware changes like dual core processor, better antenna and better camera. Yes you can say even Samsung does same thing with each new version.  iPhone 4s comes with iOS 5 and iCloud. Those are phenomenal and game changing. But all of us knew about it before.
The surprise was “Siri”. It is voice recognize system. Which understand what you speak and carry out the task. Voice recoginize system us already there much before. But people don’t use that. The problem with it is we have to remember specific commands or key word and  need to tell it. In case of “Siri” user can talk naturally and Siri figure out what you mean. The words what you speak its not important it looks for the meaning of whole thing.  The beautiful example was “ What is the weather forecast today ? ” and “ Do I need to carry Umbrella today ? “. Siri is smart enough to understand both. Yes that was ground breaking.
It is the future how we interact with Computer. In 80s there were command based interaction, 90s graphical user interface came. The next thing is voice recognize system. Siri is a serious step towards it.
With Siri iPhone 4S is the most amazing device available on earth. 

Friday, October 7, 2011

Remembering Steve Jobs

 Last 48 hours Facebook ,twitter all the social network flooded with tribute to Steve Jobs. I must say I saw some of the most innovative comments creative cartoons and  photographs of my life saying RIP Steve Jobs or remembering him. To talk about Steve Jobs some how people use their innovative brain they brings creativity or in other way they think different. Its not mac, not iPhone nor iPad ... its the idea "think different" which  is describe Steve Jobs.
Those people think different they not only just do their Job, they are there to make a difference. Those crazy people move the human race forward. Some times they appear like crazy not practical, some time they appear in black t-shirt and blue jeans in a formal meeting. But they change the way we live, they change our life.
Again going back to those comments at Facebook or twitters about Steve Jobs one thing is common  all are excellent one at that time. Excellence is another thing was very close to Steve Job. When iPod or iPhone he built it was excellent in all respect at that time. He had never settle for anything less than perfection. Its natural People use perfection or excellence with result. Actually these terms should used much before result.
If we don't plan for excellence , work for excellence then the result cant be excellent.
Steve will continue to motivate "Think differently" and will drive us for "Excellency". 


  

Saturday, October 1, 2011

ExtJs with Spring

ExtJs is an popular java script framework. To develop rich and interactive user interface, extjs is used. It is a basically library of java script component which are ready to use in webpage.
ExtJs components work very well with JSON data. If in server side we decide to Spring as framework. Its very easy to integrate ExtJs with Spring. In Spring MVC we can easily configure FTL (free marker technology)
for specific to ExtJs Component. FTL is something which is responsible to convert java objects to desired JSON object. So there can be a generic controller in Spring, Which can be derived by other controller as per application design. 
ExtJS component will talk to Spring controller which will return JSON objects.
Next thing I will try to put some code which will give a descent idea.

Friday, September 23, 2011

Timeline is in right time for Facebook.

Last week google opened its new social networking site (G+) for all user. In my last blog (http://java-pallab.blogspot.com/2011/08/my-wall-is-my-hoarding.html) we visited its key functionality and how it bring some of our social behavior on web.Now the ball was in FB's court, it has to bring in similar feature. Yesterday in F8 conference, FB has just changed the game. Mark Zuckerberg was playing the role of Steve Jobs on the stage The new sensational features of FB is time line and open graph. Through time line you can tell your life story in a collage of photos,videos,apps and other face book activity over the period of time. We can see our friends what they were up to 5 years back and how things changed. I feel its really cool. Open graph is a platform where people can chat, listin music, watch videos, tv shows together. I can see if my group friends are watching some video, I can just join them and watch together. Its just perfectly right thing for facebook or any social network site. May be the next feature is you can dine with your friends online. Those who wants have a hands on timeline can check (http://www.insidefacebook.com/2011/09/23/how-to-use-facebook-timeline-profile/) . At present its available for developers only, To activate the same register as a facebook developer.
Like any champion Facebook has just raised the game in crucial time. Which makes Google+ has to do a lots of hard work to get its pie. For users like us it just fantastic to have such crazy stuffs which no body has ever imagined ....
According to you guys what can be the next feature, and where Google+ is heading ?

Tuesday, September 13, 2011

Object Relation Mapping



In a typical web application or any GUI based application, MVC pattern is widely followed. MVC says there is a clear separation between presentation layer, processing layer and the persistent layer. I always imagine any private or MNC bank where there are front office people, Nice, beautiful soft spoken who are the user interface. And in back office some ugly, tuff and smart mangers who run the business.  
Similarly we design our java application and I assume this holds good for mostly in Object oriented paradigm.  The presentation layer sends that data to processing layer and it process as per business.
All the time data resides in objects. In Java and mostly other object oriented language, Objects are very lively. They have attributes, behavior and sometime emotions. They are also  social as they  follow life cycle , share a relations etc.  To save these lively objects in to a dead hard disc or storage is called persistence.  We can’t store live object directly to storage or database. (May be some time in future  ... this area is still under R&D ). We have to break lively object to expression less  tuple ( a row in db table). Vice versa is also very much part of the game like converting the tuple to active Object.
So in application programmer has to take care of these breaking and making of object to store in to database. And this logic also tightly coupled with different  type of databases.  To improve the situation we got OR mapping. Object  Relation mapping where an object which need to be persist hold the information about the relation/table  in database where it is going to store.  And a framework which implement OR mapping responsible for serializing and de-serializing of objects.
Some popular examples of such OR implementing frameworks are Hibernate, iBatis etc.
It reduces lots of effort and complexity of the programmer to interact with database. And programmer can always concentrate on live objects and Business.

Friday, August 5, 2011

My wall is my hoarding

Now a days when ever my laptop boots automatically in a browser facebook opens. As if it is integrated with booting process. In fact to be in facebook or any social networking site we don't have to switch on computer. They are right there in our mobile and tablet in form of Apps connecting 24 X 7. And why use social networking I never thought, may be Human is a social animal thats why. But because of social networking , it opens a new dimension of communication. For example in face book I like "Michael Jakson" music. When there is offer or discount on Mj's album Amazon shows some advisement for me. If Ford plan to launch its new model Figo in India it will make sure that Figo has a page in Facebook. Well it looks the new and hottest trend to promote product,service or brand in social networking site. And its working also. The information or content can pass form one people wall to other and reach lots of user in no time. So all most every digital content available in internet is connecting to these social networking site. And its so simple for instance if you like this particular article you can like/share by just clicking button below. And the information will be on your wall and your friends wall. If they do the same it can reach to tremendous number of people. So I thought its really fantastic and ground breaking. 
I was trying relate this with our traditional way of advertising, Where people use to put information in big hoarding or they put posters in the wall of our houses. And If I need to post some information for example I want to give the house on rent it can be put into on wall of my house. So we used to use our wall for both inflow and outflow of information. And the same thing we are doing online through social networking. 
The inception of G+ with circle,hangout concept bring more excitement. Now I can define my neighbor who can see which part of my wall I want to. And I can hangout with groups of people. It means more social stuff to virtual world. So some way we are moving towards what we used to do in real world is through computer. Its good or bad I don't have much idea. 
If I put together as they came first one to one messaging/scarping (Orkut) then the concept of wall where many to many communication (FB) now we have G+ where we have neighbor and hangout ... If we think in this line what will be next ...  

Wednesday, June 22, 2011

Apple iCloud first impression



In recent Apple world wide developer conference Apple launched its new cloud service with other major release like lion and ios 5. Well apple is known for its visionary product and game changer in the industry. Specially with recent success of iPhone and iPad. So before iCloud release huge built up happened, Steve Job's medical leave also raised lots of eyebrows. Cloud was not new to the market. Amazon, Google and Microsoft have already entered into the market with their cloud products. I found two features which make iCloud different form competitors.
1) Most of the cloud services available are some form of infrastructure( ex : computing, storage etc) are hosted on clouds. As Steve Job told iCloud is much beyond than a Hard Disc on space. In this case applications are focus rather than the platform.Various application sync with each other over cloud automatically. User doesn't have to do anything extra. Applications will automatically take care of connecting to cloud and syncing the content. In Apple's word "it just work".
2) Sdk of iCloud is open for developers. It means not only those 6 or 7 apps from Apple will be on iCloud, it will be much beyond than that. It will certainly bring out lots of innovation and amazing apps from all over the world to one platform in a nice way. 
I am waiting to have an experience of these and services. 
Oh yes one more thing iCloud is free for everybody :)

Tuesday, May 17, 2011

Divide & Rule

"Divide & Rule" also known as  divide and conquer is a very famous way to attack the problem. History witnessed this strategy work in very complex situation. It is very famous in political and military circle. It is used to influence countries, win wars and play a big role in international politics.
In corporate people also take the help of this rule frequently. In Computer Science Design of Algorithm classes it is one of technique to attack a problem.
Mostly when we plan for enterprise software previous experience says that maintenance is more costlier than developing.  With time requirements, business rules change for which  maintenance is really necessary. As Change is the only constant in this world, we can not avoid the situation. So maintainability is the highest precedence while designing or developing an application. That is the reason Object Oriented languages (Java, C#, C++ etc.) are popular. They have the feature to mange the complexity of software better than procedural language. So basically OO design means managing the complexity. Divide the complex functionality into integration of smaller/maintainable  component. How to and what extend to divide ... These are some decision which designer has to take to have a optimum solution.
So next time we face a problem this will be an handy technique to approach it ......

Friday, May 6, 2011

Web services are Self Service

In my college days ... There used to be a techno fest. It is completely organised by students starting form event planning, marketing and execution. All students were contributing in some way. With some friends I had planned to put a food stall in the college for event. The college campus was 20km away from city, and in the event normal canteen service is shutdown. So food stall is hot cash business in that situation. We wanted to make some money by creating some value.But we had no idea how to manage a restaurant for two days. We decided to buy foods from a restaurant from the city and we will serve the same food in our stall with some higher price.
And the idea worked we made some handsome profit. And the students also appreciated the food quality.....

Some time to provide some service to end user the service provider need to consume some other service. In this scenario a system need to use service/resource of another system. If it happens on web (www) then it is called web service. It is a standard way how two system can interact. Normally one system host some service the other consume. At the end of the day user get the complete service :)

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 ....