Spring is hip these days, so I decided to learn a bit more about it. I had used Avalon a while ago, I was attracted by its design by component and the way it seemed to lay out a proper infrastructure to build a server application. In the end, I was a bit disappointed, it required a bit too much glue code for my taste and did not provide that much in exchange. I don't remember if, at that time, it was advertised as IoC (Inversion Of Control) container. This experience is one of the reasons why I did not jump on the Spring ship.
I have read 3 books, here is what I thought of them, briefly:
- Spring: A Developer's Notebook, by O'Reilly: I enjoyed reading that book, because it is well written and has a good structure. It explains what is dependency injection by doing it without Spring, with Spring. But for a more complete understanding, I would recommend Fowler article. There is an interesting chapter on Swing with Spring. Minor drawbacks is that it does not talk about Spring Timers and has very little on Remoting. But I would recommend that book.
- Spring In Action, by Manning: I was disappointed by that one, because there is not much more information than in O'Reilly, it is a bit less practical to use. While it is a bit more detailed than O'Reilly, I did not find the extra information very useful in general. Remoting is better covered here than in O'Reilly, but there is nothing on Swing.
- Professional Java Development With The Sring Frampework, by Wrox: I liked that one better than Manning, but again information inside is very similar. I find the explanations more complete. Inversion Of Control is well presented (it is even comparing constructor injection with method injection). It gives examples of alternatives to XML configuration. Remoting is covered in greater details than Manning. I would recommend it over Manning anytime, and if it included a Swing chapter, I would recommend it over O'Reilly as well.
You can wonder a bit why there are 3 books on Spring, that similar. I believe there is space for other intelligent presentations of Spring. Subjects are often treated superficially. For example, look at the
Fowler article versus the best chapter about IoC, the one from Wrox, and you'll see how much more detailed it could have been. I find it a bit shocking since IoC is the basis of Spring. It would have been good to see a book explaining why Spring chose that particular design over another, for the main features, and presenting alternatives better. I would also have welcomed a book explaining the use of maybe just a few Spring aspects, but in the frame of a big, commercial application. For example after reading those books, it is not immediately clear to me what are Spring benefits when using Swing support versus other solutions. Another critic is that all those books were written around the same time, and are sometimes already obsolete. None of them describes Spring JDK 1.5 support (for transactions or JMX or metadata). The official free Spring reference book seems better in many ways.
Those books showed me Spring could be useful in some projects:
- if you want remoting.
- if you want to promote clean code, then you can promote the "Spring way". It is a good one.
- if you want to use JSF. Spring makes JSF easy and natural to use.
On top of it you get AOP for easy debugging or profiling, which is always useful at some point.
I am not convinced about Spring when it comes to:
- JDBC or database use: while Spring has a well done framework, Hibernate or iBatis have a very good API that makes Spring abstraction useless.
- MVC: it is does seem that much better than alternatives, nor much less intrusive (OK you can test it easily). Anyway I am not that big a fan of web MVC after having seen real world .NET projects without strict MVC well maintainable. I find the JSF backing beans at least as good and more flexible. Continuation frameworks are interesting too, but I am worried of their performance impact and scalability.
- Transactions: I just don't think manual transactions are that bad or ugly or less maintainable. But using Spring for them is not necessarily a bad idea either.
To me, the main alternative to Spring, and a very good one, is
JBoss. I will elaborate on that subject later in another post.
Categories: java, spring, book, review