Revising my opinion about Spring Framework

In past, at (Germany), I worked with projects based on Spring. At that time, I built my opinion about the framework: useless. It had nothing you couldn’t do without it. Everything that came with Spring could be done in simpler ways: PicoContainer or plain constructor injection for IoC/DI, plain decorators, dynamic proxies or Servlet Filters instead of AOP for the same results, WebWork simpler than Spring MVC, …

Some time has passed and, influenced by some friends in our endless discussions about Spring, I’ve decided to give it another try and I’ve started to refactor the VRaptor Web Framework, changing it to be fully Spring-based.

After this experience, I must admit: I was a bit wrong. I am going to explain it better, but I think the best part of Spring is that it already comes with many things done, ready to be used; out of the box. Furthermore, Spring 2.5 is much, much better.

Now, I have the sense that Spring brings some complexity, compared to lightweight alternatives; but not that much. This is the cost for the benefits the framework introduces. It is extremely flexible, supporting many different programming styles and idioms. I would be able to completely rewrite VRaptor to use Spring building blocks. Most of the current frameworks could be changed to be Spring-based, with little influence in their current APIs and programming styles!

People has already (re)implemented Google Guice on top of Spring. The EJB3 programming model (@EJB, @PersistenceContext, @Stateless, @Stateful, @Resource, …) can be easily replicated on Spring applications (old – 2005 – article that may be done better nowadays). One could even provide an EJB3 implementation on top of Spring, JBoss Seam could be rewritten on top of Spring and even PicoContainer could be Spring-based.

My current opinion is that Spring is a truly framework, in its original sense, because it acts as a solid base for applications to be built on top of it, without imposing any programming model, style or idiom. You aren’t required to use XML, Spring classes and even Spring annotations. The little bureaucracy comes with a bunch of ready functionality to be used, and with the great flexibility the framework has to be extended.

Today I can say I would consider using Spring Framework for new projects. I even consider it to be a good candidate to become one or more JSRs. It is a great base for applications and other frameworks to be built on top of it. Rod Johnson is a member of Java EE 6 Expert Group, which could point things to something in this direction.


5 thoughts on “Revising my opinion about Spring Framework

  1. ROFL. The Wikipedia article says:

    “For example, a team using Apache Struts to develop a banking web site can focus on how account withdrawals are going to work rather than how to control navigation between pages in a bug-free manner.”

    I think when we were in Germany you and I didn’t write the kind of software that really needs all that boilerplate. Maybe you’re writing larger stuff now? Of course, Spring 2.5 is way ahead of Spring 2.1, that counts.

    Just like developing with Struts involves hours spent debugging glitches in “navigation between pages”, developing with Spring involves hours spent with stuff completely unrelated to the task at hand. There’s a point of break-even, when the overhead starts to compensate, and it is project-specific.

  2. Fabio,

    I like spring, however I consider it overkill for small projects. The size of its codebase gives me a slight impression it is overweight, in comparison.

    Another thing which amuses me is the fact that Spring became de de-facto option for J2EE. I don’t think Pico, Guice, Hivemind, or even plexus (which I consider the second most used – Think Maven2) being options. I think this architectural myopia, among other things, brings me a feeling of lack or alternatives.

    Until someone play Gavin King and show it could be done differently. OTOH, I expect Spring to be more granular, with dependencies becoming smaller, thus letting me use a choose-what-you-need approach.

  3. Yeah I also consider Spring is very worth to consider. But it should be done with good control, else you can get it quite wrong too. This article also discuss quite good information on how important it is to be in control.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s