Gunnar Hillert's Blog

Sunday, June 7, 2009

Book Review: Spring Web Flow 2 Web Development

Spring Web Flow 2 Web Development by Sven Lüppken and Markus Stäuble is the currently only available book on Spring Web Flow 2.0. The book covers all the components that are part of the Spring Web Flow distribution such as:

Spring Web Flow

Spring Faces

Spring JavaScript

Additionally, the book also provides an overview of Spring Security. The book comes with example code for many of the chapters.

The provided examples, however, could have been a little more consistent. The main source example in this book is covered in chapter 5 (A simple bug tracker). I liked the given example, as it does not require a database. This makes it easy to understand the Spring Web Flow specific problem domain. However, considering the fact that the authors also talk about Spring Security in other chapters, it would have been nice, if they had used the bug tracker example throughout the book in order to create a “complete” application, that ties together Spring Web Flow, the persistence layer and Spring Security. Unfortunately, the code examples given in later chapters don't refer back to the bug tracker example. Instead, chapter 6, for example, uses a shopping cart example.

A further minor annoyance is that the source code for 2 of the chapters still contain the eclipse project files used by the authors. This may be confusing for some users as these project files still point to Microsoft SQL Server drivers on a windows D: drive. I, for instance, use a Mac...

In chapter 2 the book discusses on 4 pages Ant and Maven. I think it might have been simpler for the understanding of the book and the provided source code, if only one build system was used, e.g. Maven. Some of the code examples provide Ant and Maven build scripts but some other ones provide support for Maven, only.

Another anomaly was, that the book describes the installation of the Spring IDE plugins for Netbeans and Eclipse on 7 pages but then the authors mention in passing only that they are using Microsoft SQL Server as underlying persistence store for their example. As many Java developers may not have a MS SQL Server license, it may have been better to use open-source Databases such as MySQL or PostgreSQL.

The example in Chapter 3 uses HSQLDB for its database but earlier (Chapter 2) the authors use MS SQL Server. For consistency and simplicity reasons the book could have stuck with one database.

Chapter 4 deals with Spring Faces. The authors should have mentioned JBoss Seam, since Seam solves a similar problem as Spring Web Flow but having a default focus on JSF.

The book provides an entire chapter on JSF integration (Chapter 4). As JSF is a widely used framework and Spring Weblow provides native support for JSF. It would have been nice though, if support for other frameworks such as Struts 1 and 2 would have been illuminated.

As part of chapter 5, the book also provides information on Spring JavaScript. While it is part of the official Spring Web Flow distribution it is not necessarily essential for the working of Spring Web Flow and even its spec lead Keith Donald mentioned at the Atlanta Java Users Group (AJUG) meeting in November'08 that it maybe extracted into its own project in the future.

The section in chapter 5 which starts on page 165, the Web Flow Configuration, felt repetitive to parts of Chapter 3 (pages 53) and should have probably merged with that section. Chapter 5 also contains a larger section on Apache Tiles integration. One thing that I did not understand was how Tiles matters in terms of mastering Spring Web Flow. Generally I don't mind explaining additional pieces of information around the edges of your problem domain but if that happens on 5 percent of the book, it needs to matter within the context of the targeted subject. On a site-note: Take a look at SiteMesh for your templating needs. I strongly prefer it compared to Tiles.

In chapter 6 the testing of your Spring Web Flows is explained. This was an informative chapter and I particularly liked mentioning of EasyMock.

In chapter 7 the book primarily details Spring Security. In my opinion, it provides too much Spring Security centric information. For example, the chapter describes how to create and write your own AccessDecisionVoter. In my opinion it does not help and is unnecessary for the understanding of Spring Web Flow. At most I would have chosen an example that uses a DB-backed security implementation using default Spring Security functionality.

To me, chapter 7 was a bit strange. It provides 16 pages of information introducing Spring Security but the actual integration of Spring Web Flow with Spring Security is accomplished in merely 4 pages. Most interestingly, that's where the book simply ends. I missed something like a wrap-up, that summarizes what the book covered and where to continue on.

In Appendix B the authors provide an overview of Springsource's dm Server. Personally, I think that dm Server is an interesting offering. However, I don't understand why this appendix even exists in this book. It is neither important for the understanding of Spring Web Flow, nor do the authors explain why this appendix exists.

Here are some further thoughts: Throughout the book, I like the use of Maven for building the examples. It certainly makes it easy to understand the examples' structure.

I think for the understanding of Spring Web Flow, it unnecessarily complicates things, if you present examples that require JNDI for establishing database connectivity. Furthermore it binds you to a concrete application server, which in this case is Tomcat.

Except for a for a very brief mentioning on page 224, the book never talked about the applicability of Spring Web Flow in the context of RIA frameworks such as GWT, Flex etc. Is there a use case for Spring Web Flow e.g. for coarse grained server state for large, complex applications?

It would have been nice if the book provided an overview of other frameworks that handle conversational state such as JBoss Seam. Additionally, since the books was published in March 2009, it could have described some of the planned conversational state management support planned for Spring 3.0.

Furthermore, it would have been great if the book had also mentioned how Terracotta can be used to back Spring Web Flow conversations. Terracotta provides an interesting reference application detailing that possibility.

Anyway, the book follows generally the Spring Web Flow documentation. The question is how much more value does the book add compared to the reference documentation. Overall, I have a quite conflicted opinion about this book. I think, if you are interesting in JSF integration or the bulk of the additionally discussed technologies (E.g. Spring JavaScript), then this book may add enough information for you. It certainly provides some useful information regarding Spring Web Flow 2.0.

Unfortunately, it contains quite a few inconsistencies and it is overall not an easy read. However, it is the only currently available book dealing with Spring Webflow 2.0. On Amazon, I gave the book 2 out of 5 stars.

However, if your professional background is in web-application development using Java or other OO languages, then you are probably more likely to skip or cross-read sections of the book. This is because the book starts out with practically no initial pre-requirements, and thus you might be familiar with some of the discussed areas.

The book gave me an excellent overview of Flex's capabilities, and they are all explained thoroughly and are easily understandable. Also, this may sound silly, but I particularly liked the refreshing fact that the book is in color, unlike most other IT books.

Furthermore, the book explained Data Binding (Chapter 7) very well. This is something I was not familiar with coming from the Java world. The chapter illustrates the concepts of one-way binding, two-way binding and making your own variables “bindable” using a metadata declaration, which is basically an annotation in Java parlance.

Another feature I liked a lot was View States (Chapter 12), which allows you to rearrange, group and reuse components within your application.

I wish the book provided more information for further reading. I understand that certain concepts are beyond the scope of this book, but it would have been nice if those had been mentioned and links or recommendations for further reading were provided.

For example, while AMF is mentioned on page 8 and on page 157 the book briefly talks about the Webservice and RemoteObject component, the book should have also mentioned BlazeDS as one of Flex's core technologies for communicating with back-end servers.

And for more complex applications, the book could have at least pointed out some of the available MVC frameworks for Flex and some pointers of where to read more about them (E.g. Cairngorm and PureMVC). Well, and then there is Degrafa, the declarative graphics framework…

While the author explains the aspects of using CSS in Flex applications very well, he could have further stressed that Flex uses a subset of CSS, which in certain areas behaves differently compared to CSS you more typically use in HTML pages. He should have enumerated some of those pitfalls.

Having said all this, these issues mentioned above are minor in nature. Overall, the book was a fun read! And particularly to Java web-developers, Flex may very well be THE contender for application user interfaces moving forward. One of the great things about Flex is that even the standard components look very good (and should be good enough to please your boss), and your application looks and behaves consistently across various browsers. Oh, and yes you can run the same application on the desktop as well (Chapter 15).

This book will definitely help you learn and master Flex, and you should be able to produce functional user interfaces quickly. In order to learn more about integrating Flex with your Spring powered back-end you may want to also consider looking at “Pro Flex on Spring”.