Wednesday, December 21, 2011

Which Frameworks We Should Choose

It all depends on the size and nature of your project, There is no single tool which can be best for all projects.
Before deciding which tool we should use for our project we should consider many things
·         How much time we have to develop this project.
·         Do we have the required expertise.
·         Or is there  any learning curve involved and how much time it will take.

Now suppose we have given a project in which user wants to see many reports .If we try to develop the reports in HTML, JSP or any other programming language it will be a bad decision. Instead we should use the most efficient tool for it which is Crystal report.
Now let’s look into the most reliable options , We all know we can divide our project in following three logical layers
1.       Presentation layer (Examples : Data entry and retrieval pages)
2.       Business Layer (This is the layer where we implement business logic)
3.       Data Layer (DAO,JDBC)
Following is a list of most appropriate options we have on each layer
1)      Presentation layer
·         Struts
·         ADF
·         JSF
·         Spring MVC
2)      Business Layer
·         Spring
·         EJB (Stateless/ State full Session beans)
·         POJO based business objects
3)      Data Layer
·         DAO
·         Hibernate
·         EJB (Entity Beans)
·         JDO
I will discuss the frameworks/Technologies I have used
Presentation Layer (Struts):
                Struts is a true MVC implementation and has following advantages
o   Once learnt , the development is a fast since they allow you many things out of the box
o   Easy to maintain
o   Easy to transfer the knowledge since everything has done on the struts standards.
o   Validation Framework , you only need to add infect copy paste a line in an XML file to enforce a javascript validation check on your field. It also provides you many other good java script functions.
o   It provides you Powerful Struts Tag Library.
o   Centralized File-Based Configuration.
o   Struts encourages consistent use of MVC throughout your application.
      Disadvantages :
o   Bigger learning curve for new people.
 Conclusion  : You shouldn’t use Struts for a small project having few pages. This frame work is meant to be used for larger web applications.
Business Layer (POJO based business objects)
POJO (Plain Old Java Objects) are the best way to implement business logic , because of following advantages
o   Easy to write
o   No extra configuration involved
o   Deployment is easy as compare to EJBs
o   Reusability
NOTE  : We can develop our own library containing all those business object to be used in future projects and to get rid of re-inventing the wheel every time.
This library may include
o   Utility Package (Different Utility classes for date/String/Number Manipulation etc)
o   IO package
o   Business Objects Package
Business Layer (EJB Stateless/ State full Session beans)
This is the best solution for large scale applications where you need your server to take care of Transaction management, Object pooling and many more  .But it has many tradeoffs

Data Layer(Hibernate)
       Really a great framework to use, it is basically object relational mapping (ORM) framework
Advantages :
o   Can create all the data access code for you using hibernate tools
o   Good IDE support
o   Easy to manage
o   Easy to change
o   Database Portability
o   HQL ,  powerful SQL alternate
o   Many more
o   Bigger Learning curve

Data Layer(DAO)
o   Before ORM tools like hibernate this used to be the best solution , but now since you can create the data access code using any ORM tool why should we write all that code?

Advantages of using the open source frameworks are
·         Once learnt , the development is a fast since they allow you many things out of the box
·         Easy to maintain
·         Easy to transfer
·         Scalable
·         A lot of stuff for learning is available
·         Since you have the source code so you can tweak it easily if you want
I would recommend Struts, POJO business Objects , and Hibernate.
I think what we need here is a proper methodology to follow and reusable code .We can try to build a library of classes which can easily be reused in other projects .With proper Java Docs of that library it will be easy to reuse classes rather than reinventing the wheel every time.