When it comes to Java programming, the word ‘framework’ is used quite often. A framework is basically an encapsulated way to do something (usually) more efficiently. It is a collection of efficient processing power that is, hopefully free, and wrapped up nicely into one or more libraries. There are many Java frameworks out there, far too many to mention in this one article. I’ll be discussing three of the big guys. You’ve probably heard something about them by now, they are Struts, Spring, and Hibernate. If you haven’t heard anything about these yet, and you’ve been in the field for a while, I recommend Java Google Groups.
Struts framework helps to manage the UI portion of the application. It handles the tangled request, response and session transactions quite elegantly, some say that it is outdated, but I still think it has a place in the community. The most difficult part of understanding the Struts framework is realizing how the action and form classes interact with each other. This relationship between action and form classes is defined within the Struts XML Configuration file. This framework also offers a collection of tag libraries that are used to eliminate the JSP from the JSP pages (I, personally despise tangled, hard to debug JSP pages full of Java), and encapsulate the Java code inside the tag library classes.
This Spring framework is probably the most recent of the frameworks mentioned here. It is based on dependency injection and a different type of programming methodology called, Aspect Oriented Programming. The most difficult part about learning the Spring framework is getting your mind around this new programming methods and understanding how to properly set up the Spring XML Configuration file. When the application is executed, the constructor parameters for the core objects in the application are configured in this XML Configuration file. The Aspect Oriented Programming strategy can be very quickly summed up by saying that all of the child objects get instantiated first then are injected into the parent objects, thus the phrase, dependency injection. I personally have not yet embraced Aspect Oriented Programming and I have heard other developers claim that it is a step backward in the evolutionary cycle of Java programming due to a similarity to the archaic procedural programming ways (Blaspheme).
The Hibernate framework is a framework by which business objects get populated ‘behind the scenes’ from database data via a Hibernate’s Configuration XML File. The most difficult part about programming with Hibernate is correctly configuring the Hibernate session factory, and equally, if you’re working in a database that does not enforce relationships (mySQL for example), correctly configuring the XML to describe the relationships between the tables can pose quite a learning curve as well. I want to say that I’ve used several different Hibernate-type tools, including .NET’s version, and the relationships are extremely important to enforce, especially if you are working with a database of roughly 10 or more tables. Once the configuration is correctly in place, Hibernate is a fantastic framework to program with, and it saves a tremendous amount of time, once you learn how to use it.
There are countless other frameworks throughout the Java programming language that I have not mentioned here, or in any of my previous articles. Most of you have probably programmed some kind of framework of your own by now, if you had several years of experience in programming. The ones that seem to catch the eye of the popular world are usually, the ones we should pay attention to.
A good framework can save a programmer a lot of time, not to mention, a lot of stress as well.