Dependency / IoC via Spring.,
November 15, 2008 at 6:29 PM
Good question. In simple words: If you want to use any framework (e.g. Struts, Hibernate, etc...) within your application, your code has to use the API provided by that framework. This makes your code that framework dependent. Spring minimizes this by rather injecting such dependencies into your application (As you go on declaring various configurations in XML files). Hence your application code is much cleaner.
That's why Rod Johnson et al. say: "Application code written as part of a Spring application can be run without Spring or any other container", yet it's not 100% freedom. E.g. for writing Spring MVC, your handler/controller has to extend one of the controllers (AbstractController) & implement "handleRequestInternal()" method that returns ModelAndView object. That's the reason why they also say: "Lock-in to Spring is <b>minimized</b>".
Thus, not only Spring code, but also any code (preferably AOP, Transaction, Security related) can be injected. This makes your application code look cleaner. (but at the same time highly configured in the background).
However, in my opinion, every new framework/technology has proclaimed to have offered to allow developer focus on business logic but only forthcoming time will reveal the truth. Because just like how people used to dream of paperless office during computer era which ironically has proven a myth as the paper usage has increased dramatically causing more & more trees chopped.
So let's wait & watch whether this Frameworks proliferation end up in making a developers' life more miserable or let them focus on business logic.