It is really a tough deal for a new programmer to figure our why should he/she use a framework like Spring. Developer or programmers who worked with single tire framework like Struts or Hibernate may find it’s usability easier than everyone else. At the beginning of J2EE applications 1999/2000 (I was not even start my graduate school) it brings out a new fresh wave of in web based application through core middle-tire concepts. Though those applications takes much afford to develop and more complexity on overall process. Since new problems and challenges rushed to us day by day. J2EE and other web applications shows up with some crucial problems like followings:
J2EE applications usually carries excessive amounts of protocol code: Try/catch blocks for JDBC, or transfer objects requires a lot of bulk code that is totally unnecessary compare to business logic but mandatory for J2EE structure.
J2EE applications often use distributed object model: Distributed object model(a remote object whose methods can be invoked from another JVM, potentially on a different host) creates extra codes where most of those are simply duplication. Distributed application is much complicated than the co-located(same place) one.
Unit test in J2EE applications are tough The basic design of J2EE didn’t consider unit testing. As a result EJB and most of J2EE APIs are hard to test out side of server.
Over use of EJB: EJB was specifically designed for internally distributed and transactional applications. But it was used in many place where it was not appropriate.
It is proven by experience a framework is much flexible than traditional tool-enabled code generation. Configuring the behavior of simple piece of code much easier by using a framework. Many developers attempt to write a framework for these reasons. Spring comes up with solutions of many flexible facilities. Spring framework contains many features that help to commit a web application in a easier way. Here are some core features of Spring:
Inversion of Control (IoC): Most probably the best feature of this framework. Advertise the example of Hollywood principle of “Don’t call me, I will call you”. In traditional way of class library, Application code is responsible for total work flow. As a result calling out the class library is necessary. But by Inversion of Control framework code invokes application code, coordinate overall work flow.
Dependency Injection: A kind of IoC that maintains push configuration. At the runtime, the dependencies are pushed into application object. Thats why Dependency Injection objects never need to load custom properties or search a database to load configuration. The framework does the whole thing.
Aspect Oriented Programming (AOP): AOP separates crosscutting concerns into single units or aspects.
By: Md. Shahjalal
References:
1. http://www.wrox.com
2. Expert Spring MVC and Web Flow
3. Java Loby