JavaPulse

a finger on the pulse of the freelance Java™ market in the Netherlands

Spring in Action

Posted on | 30 August 2006 |
Tags: | |


These days, the latest Java frameworks try to achieve a balance between coding and configuration. Spring provides solutions for many of the common problems in building an enterprise application, by applying IoC (Inversion of Control) and AOP (aspect-oriented programming). The framework off-loads a lot of the complexity of an application from code to configuration.

The power of Spring is accredited to 2 things: IoC and AOP. IoC means that instead of an object having to retrieve its own references to other objects, the linking of the objects happens via the config file. This process is called wiring. IoC allows for loose coupling so that your application doesn’t become one gigantic blob of dependent objects. Independant objects are easier to test.

The second feature, AOP, allows for separating security, transactions, and logging (the most common aspects) from your class at hand so that it can get down to business to fulfill its life’s purpose without taking detours. How many of us have had to copy transaction and logging statements from class to class then changing the constants for the class names? UGH. I’m so glad those days are over. The aspect control in Spring does not provide as fine-grained control as AspectJ, but more control is usually not needed.

Lastly, Spring is an umbrella framework over the entire application. It provides easy hooks to integrate other MVC (Model-View-Controller) and ORM (Object-relational mapping) frameworks. Although Spring provides alternatives including its own MVC framework for the front-end, it seems not to be any better than Struts. They both require two classes for every form submission. While Struts requires Form and Action, Spring requires the combined Form/Action and validation. Struts seems to have a slight advantage by providing declarative validation. Spring also provides alternatives for ORM, but Hibernate is the most popular one. Details about Hibernate will take another post. Further, I will be documenting the building of my own Spring-Struts-Hibernate application in a series of posts.

Related links:

Comments

Leave a Reply