Book Comparison: Spring Recipes and Pro Spring 2.5
Book Comparison: Spring Recipes and Pro Spring 2.5
Join the DZone community and get the full member experience.Join For Free
Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.
Since about 2 years ago I have been an evangelist for Pro Spring book in the Spring Forum, the best and definitive book to learn Spring from the scratch (really I learnt Spring from there). Now Spring has improved with new features, and new modules, so new books are required.
I was eagerly awaiting the Pro Spring 2.5 book. Before that I had read Spring Recipes, which I wrote an opinion review about - I consider this book the best written until now. It is fair now to do a comparison between the two books, to help new and existing Spring programmers/developers to decide which book to buy.
It is important and fair to say that I read all of Spring Recipes (physical book) and I am just doing a surface read of Pro Spring 2.5 (ebook/pdf version )
Both show us Spring almost with the same way (reasons, modules, distribution, etc) and Spring IDE installation. I wonder why authors of Pro Spring 2.5 chose the IntelliJ IDEA, while Spring Recipes instead use Eclipse. Now both books have two chapters to teach us about Spring and its Beans Configuration. Both basic and advanced chapters exist; a fine approach to explain IoC and DI and the same case about the Factory Beans, p namespace is used in both books, important rules (good amount) about beans declarations/configuration are explained too. Annotations are beginning to be covered.
I enjoyed researching Aspects, an important topic related to Spring. Both books have 2 chapters for this. Each book has its own style; for instance Spring Recipes use a concrete example (arithmetic/unit calculator example) that teaches with logging and argument validation, the differences between use AOP and not (pictures of proxy design pattern are used here, to provide a better understanding).
Pro Spring 2.5 uses an example related with a simple "MessageWriter" class. Here AOP is used with Security (applying security in this cases is a little complex). Furthermore Profiling is applied too, annotations are applied in a simple way; proxy is mentioned here too (you won't find any pictures for a better explanation).
Now for the advanced chapters for AOP - both books use 100% annotations (with/without regex of course). Pro Spring 2.5 shows us an explanation for each type of annotation. Something important is that Introductions are explained for both books and Load-Time Weaving too, furthermore something interesting is that Pro Spring 2.5 has a sub topic about Performance and Health Monitoring.
In a fair comparison Pro Spring 2.5 is perhaps overcomplicated in examples to teach AOP, but is little more detailed in theory. Perhaps you should read these chapters twice. Spring Recipes has concrete examples which are very easy to understand. The theory is pretty nice too.
Pro Spring 2.5 has a dedicated chapter called Spring Schemas and Namespaces (again IntelliJ IDEA is mentioned but now Eclipse IDE is used too - for validation). Instead Spring Recipes has many of theses features spread in all book (of course according for each chapter). therefore here we have a dilemma about central/distributed information (I consider both approaches fine).
An interesting and important chapter in Pro Spring 2.5 is Spring Patterns, This chapter has also mentions:
- Creational Patterns related with Singleton, Factory, Builder and Prototype
- Structural Patterns related with Proxy, Wrapper and Decorator, Facade
- Behavioral Patterns related with Observer, Strategy
JDBC is an important topic. Pro Spring 2.5 has a lot of heavy theory, with many topics explained, and use many UML diagrams. Perhaps the examples are a little complicated and it's a long chapter. Oracle is used as an example in the configurations (for instance CallableStatements features and others).
Spring Recipes has other approach, a SQL diagram is used as a basis and it is aplied with many options available with JDBC support (templates, for instance). The chapter is not very long but is very concrete, Apache Derby is used.
Here Pro Spring 2.5 has an excellent chapter for Ibatis/Spring integration which is concrete and easy to follow (One-to-One, One-to-Many, Many-to-Many relations are explained very well and nice code examples!).
Another important topic is ORM persistence. Pro Spring 2.5 has a chapter entirely dedicated to Hibernate, again Oracle is used. Hibernate with/without Spring (DaoSupport/Session) is explained here. Some interesting topics are Preventing Stale Data Updates and Object Equality, and Transactional Behavior is explained too, about performance Lazy Loading is explained with many options and a good amount of UML diagrams. Annotations are not covered in a deeper way and JPA is not covered in either book.
Spring Recipes has a chapter about Spring ORM support. Here Hibernate and JPA are explained in a parallel way, discussing configuration and its differences. Annotations for both are well covered.JPA with Hibernate As the Engine is covered too, which is a nice approach. Spring support for both options is well covered (with DAO support, Transaction Manager) Derby is used again.
Now we have a critical comparison - Spring Recipes has a chapter called Spring Support for JMX, E-mail, and Scheduling. Instead Pro Spring 2.5 has three chapters for
- JMX with Spring (chapter 20) well cover
- Mail Support in Spring (chapter 13) well cover
- Job Scheduling with Spring (chapter 12)
For scripting, both books have its own short chapter covering Bean Shell, Groovy, JRuby. Pro Spring 2.5 has also got a mention to Transaction and AOP in this chapter.
Each book has its own chapter on this. Pro Spring 2.5 has an table explanation for Isolation Level, Propagation Behavior with a brief explanation. Furthermore this chapter has code examples using JDBC but with these details
- Nontransactional Code
- Programmatic Transaction Management (Using the TransactionTemplate Class )
- Declarative Transaction Management (TransactionProxyFactoryBean)
Spring Recipes has almost the same features as above (of course with other approach). With Isolation Level and Propagation Behavior - this book has something that I never seen in other book - code examples of the differences between Propagation Transaction for Required,Requires_new attributes (for each case) and Isolation Levels the same good idea is written for ( read_uncommitted, read_committed, repeatable_read, serializable). Therefore its gives you a clear idea about what happens with each option and you see clearly the differences between them (pictures are used too to get a better understanding). This is a really excellent approach!
Pro Spring 2.5 has a chapter called Web Applications with Spring MVC. In Using Handler Mappings SimpleUrlHandlerMapping is used, for Spring Controllers
- AbstractController (snippet of code is used), useless to understand real code
- ParameterizableViewController (snippet of code is used) to understand real code
- MultiActionController (more xml coded used)
You will se an code extract and an xml bean for interceptors. There's good coverage of Views, Locales, and Themes, and also for Command Controllers related toUsing Form Controllers,. AbstractWizardFormController has the same approach, and File Upload is covered in a concrete way, as is Handling Exceptions.
There is a section called Spring and Other Web Technologies - this part of the chapter is dedicated to tags like Spring Tags, Form Tags, for Velocity, FreeMarker, XSLT Views (well cover), and for PDF Views, Excel Views (short cover), Tiles (Spring Recipes not cover this). JasperReports is included here and there is a section called Spring Conventions Over Configuration which is an interesting approach. There are simple explanations and simple code example which help to easily get an understanding.
Spring Recipes has a twochapters instead:
- Spring Portlet MVC Framework (same approach that the others chapters, therefore well cover)
- Integrating Spring with Other Web Frameworks, excellent cover for integration with Struts 1.x, JSF and even for DWR (Ajax)
Spring Web Flow
Spring Web Flow, Pro Spring 2.5 has a good introduction with UML diagrams, how get the distribution and an explanation of the distribution and its dependences. This chapter starts with a basic example of one state, and then a deeper explanation of each type of state with a snippet of xml code. Many of the features of SWF are well covered with a good amount of UML diagrams. Furthermore Integration with Spring MVC is very short - while the chapter titled Securing Flows with Spring Security is well covered with step-by-step instructions. Sub flow is almost not covered at all - it gets a brief mention.
Spring Web Flow for Spring Recipes has another approach - this chapter presents a scenario showing features in a fast way (code, configurations, flow definitions). It's shorter than Pro Spring 2.5 but gives a reall good understanding, with many flow diagrams. Again Sub flow is almost not covered. Something that Spring Recipes has that Pro Spring 2.5 doesn't is Persisting Objects in Web Flows and Integrating Spring Web Flow with JSF is only covered in Spring Recipes
Both books have their own features. I think SWF is an important module, but a dedicated book would be better.
Pro Spring 2.5 has a chapter titled Using Spring Remoting covering:
- Web Services with JAX-RPC (Apache Axis well cover)
- Using JAX-WS Web Services (SimpleJaxWsServiceExporter,XFire)
- Web Services with HTTP Invoker
Spring Remoting and Web Services in Spring Recipes has the following topics
Spring Recipes has a chapter called Spring Support for EJB and JMS, while in Pro Spring 2.5 neither EJB nor JMS are cover. The same analogy exists for Pro Spring 2.5 which has a dedicated chapter called Spring and AJAX and another very interesting chapter is Spring Performance Tuning.
For testing, Pro Spring 2.5 offers Testing with Spring and Spring Recipes has Spring Testing Support. I prefer Spring Recipes because it deals with two versions of JUnit and has better approach to teach and better cover annotations.
I could write a deeper comparison, but I want to keep this simple. And for obvious reasons these books do not have the same order of chapters in a 100% (and specially each sub topic for each chapter); and one book has one author while the other has many authors.
Both books are nice- between them, each one has some exclusive/dedicated chapters that other book not explain for instance:
For Pro Spring 2.5
- Spring Patterns
- Spring Security (A critical chapter)
A beginner/medium Spring reader would probably prefer Spring Recipes because has more action and not much heavy theory. It is really better structured (define problem, solution and how). The word Recipes describe this book perfectly.
If you can buy both books do! They compliment each other well. But if you only can buy one, I would suggest Spring Recipes (more action and concrete theory). Pro Spring 2.5 is not bad, I consider this book more professional/academic to dig in Spring knowledge.
If you have still have some doubts with my opinion, see the customer reviews in Amazon. The final decision is always yours.
Opinions expressed by DZone contributors are their own.