Thursday, October 14, 2010

Spring Aficionados vs. Spring Bashers

The Spring Applications Framework has been an essential and powerful platform for Enterprise Java development for many years now. Yet, surprisingly, every now and then heated discussions still spark in various forums and blogs regarding its benefits. I find there are two general types of Spring Framework users.

1) Programmers who have always looked for ways to craft better software, to save time and effort, who wrote their own micro-frameworks to simplify, reuse, facilitate... Such programmers never stop learning and are only too happy to find better, more efficient ways. They love to learn from others, and they love to share their knowledge. Most importantly, they don't buy into the "silver bullet" dogma and tend to critically investigate before deciding whether the solution suits the problem at hand. Many of such programmers are also plain "lazy" - in a good way: they hate having to tediously write the same [spaghetti] code over and over again, working long hours on something that does not involve creativity or bring artistic satisfaction. These people are proud of their craftsmanship, and they appreciate good code when they see it. Such folks embraced Spring as soon as they first experienced it (tried and understood it!) - mostly because the framework was addressing all the concerns any good programmer was already passionate about. It didn't matter whether they found Spring on their own or were introduced to it by a coworker. They did not need to be convinced, they already where in that boat. The best part was that the framework had turned out absolutely non-invasive. Any developer or team could choose which parts of it to use. The only basic condition was: program to interfaces, use dependency injection and POJOs (vs. being restrained by clunky combersome interfaces defined by some specification), strive for quality... These are all just some basic principles of good programming, Spring or no Spring... One really has to dislike chaotic disorganized programming to be a Spring aficionado.

2) People upon whom Spring was forced by some architect/manager/new hire/etc. - when they least expected. Normally, such folks felt quite comfortable with the tools and methodologies they used on the daily basis. Or simply didn't care one bit what they used. (Not all, of course. I don't want to offend those who did care but simply loved the EJB2 spec. :-)) They were rarely inclined to improve anything or change the status quo. (Otherwise, their curiosity alone would have led them to a discovery of the Spring Framework much earlier.) For such people, Spring was "just another framework" that they didn't need. Many of them instantly rejected it without even trying to understand it. For many, it was an ego issue. They had been doing something for years - often holding senior positions in their organizations - only to have some "new guy" to tell them (and everyone who'd listen) that there was a better way... Some of those people eventually took their time to investigate with an open mind. Some never did, they still don't really know what Spring is and how it may be used. And some continue to bash it any chance they get. You'd hear them with all seriousness "comparing" Spring to... Struts (apples to oranges), talking about Spring getting more "bloated" with each release, Spring configuration or code being unreadable (as if it is the framework's fault not the particular developers'), etc. They are the ones who produce bad Spring-based applications, and then blame it on the framework itself.

Yes, I love Spring. (Not sure if that was clear...) I love it for its elegant programming model, non-invasiveness and granularity that allows me to use the parts of it I need for any given application. Just choose what suits your problem and include that into your solution, nothing more. That is something the Spring bashers seem to have never learnt about the framework. No, Spring is not a silver bullet. It is not supposed to solve all your problems. It is there to significantly simplify enterprise Java. It allows you to freely choose between (and painlessly swap if necessary) various implementations of different technologies, it encourages the better programming practices - for those who care, and it gives developers many powerful tools that they may use if they choose to.

Finally, to answer some critics, Spring does not lock you into using vendor-specific (e.g. SpringSource) implementations of anything. It makes it easier to swap between the available options.

I should mention the obvious: using Spring by itself does not ensure good results. One should still be a good programmer to write good code. One must study and understand any framework or tool before applying it. (Needless to say, right?) An incompetent programmer who was told to use Spring would still write an incoherent, bloated application with countless unnecessary dependencies and couplings, with unreadable configuration and source code. One should not judge the Framework based on such poor samples created by those who simply can't design and code.

5 comments:

  1. Hello Constantine,

    I Googled your name in search of a forum post I had read on the Spring forum so as to post my little newbie post bit
    http://forum.springsource.org/showthread.php?t=64147&page=3

    Your posts on the Spring forum are very helpful !

    I didn't know you had a blog though.

    ReplyDelete
  2. @Stephane
    Thank you for your feedback. Glad to know that it helps someone. As you see, I rarely blog. Most of my posts here materialize after I find myself addressing a particular issue more than once in other forums, such as Spring Forums. So, these are just the more organized summaries of off-the-cuff posts I have previously put out elsewhere...

    ReplyDelete
  3. Hi.Your posts in forum and this post is good.Is there any way to learn the nuances say in Spring webflow.I could not find a book like 'Effective Java' for Spring or I am not sure.I may be ignorant.would appreciate your thoughts on it?

    ReplyDelete
  4. @sivaram: Sorry for the delayed reply. There are quite a few good books on the Spring Framework. However, due to the dynamic nature of the framework, some of the material in a book gets obsolete as the framework evolves. My favorite sources for all things Spring are:

    1) The SpringSource reference guides (for the Spring Framework, and other Spring projects such as SWF, Spring Security, Spring WS, etc.) These reference manuals are always well organized and well-written. However, they don't always cover all the details, and further digging may be necessary.

    http://www.springsource.org/documentation


    2) Spring Sample Code repository. This provides a wealth of useful information and great examples on how to configure and code Spring applications. This is ,in my opinion, the most essential source of information - if you want to learn and use Spring.

    https://src.springframework.org/svn/spring-samples/

    The above are my primary two sources for Spring knowledge.

    Keep in mind that there are lots of different blogs and web sites that post tutorials and code samples, however I often find some of those very misleading, obsolete, or even incorrect. So, make sure you get the "ultimate truth" from the source (SpringSource) first. Hope this helps.

    ReplyDelete
  5. We now refer to each other around here as 'Paragraph 1' types and 'Paragraph 2' types.

    ReplyDelete