Choosing the right web framework can be a daunting task, even for the experienced. How many of us have time to tinker with all of them, let alone just the popular ones? Due to books like 'The Art of Java Web Development' you don't have to spend your lunch hours, weekends or long nights downloading, installing, reading docs, and building something more than a hello world; it's already been done for you. And that time is most likely already being soaked up with your current state of affairs. This book takes you on a broad tour of the following:
- Where we are today with web frameworks and how we got here. It goes into details about the evolution of pattern-based frameworks and sets the stage for creating a simple application in the later chapters.
- Review of some of the arguably more popular web frameworks: Struts, Tapestry, WebWork, InternetBeans Express, Velocity and Cocoon.
- What the author considers to be Best Practices when using and designing web applications with a web framework.
I've tackled the problem of evaluating web frameworks myself. As a leader of a local user group which is dedicated strictly to the study of various web frameworks out there, www.frameworks-boulder.com, being a frameworks committer on the Expresso project, and a member of the Wafer Project, I know that this is a difficult and time consuming task, so this book is of great interest to me.
Part I : Yesterday and today in Web frameworks
Just like we have done on the Wafer Project, the author sets the stage for a standard application that he will develop on all of the applications as a way to level the field in comparisons. While I feel that the application he has chosen is rather small, it does sufficiently serve the general purpose. What is rather frightening is that the author further sets the stage by developing this sample application using no framework, just simple Servlets, which is almost like seeing a car accident: its an awful sight to behold but you can't help looking at it! Then the author continues to prolong the readers pain by doing the sample application again in JSP, then with only JSP tags and lastly with JSTL. While those chapters were very painful to read the author does make a useful point, although not directly, that web frameworks are a better solutions compared to the history of web development!
Part II : Evaluating the frameworks
Most of the painful reading is over and unless you have written a web application like the one towards the beginning of the book, then you shouldn't be sentenced to cover them, so skip straight ahead to Chapter 4 where the author sets the stage for a new sample application which he will build with the frameworks he has chosen.
For those of you who have little time on your hands, proceed straight to Chapter 5 where the author begins the framework evaluations starting with the ever so popular Struts. Although I don't publicly admit to knowing Struts, it does appear that he is reviewing Struts 1.1 which is good since it is the latest distribution release. As to be expected, having an example to show how the framework operates is very good and the author does a good job at highlighting the strengths that come with Struts like the centralized XML configuration and the tag libraries, along with some of the newer features like declarative validation; however, the author neglects to mention many of the problems with the Struts framework like inheritance or Action, or the complex usage of form beans along with other arguable issues.
Along with Struts, the book also covers other frameworks like Tapestry. Tapestry is one of those frameworks that has recently hit the scene and having never used it myself, I found the chapter not only resourceful in explaining how to configure and build with Tapestry, but also in highlighting what sets it apart from the rest; and that is, its focus on components. Next was Webwork, version 1.x, which is unfortunate since we're so close to the 2.x release; however, given writing deadlines authors are faced with I suppose you have to stop writing at some point. It's unfortunate because Webwork 2.x is about to hit the scene any week now and the possibilities are much greater than what was possible in 1.x. See Building with WebWork2.
Struts, Tapestry, and WebWork are all standard, popular, open source web frameworks used for building extensible, maintainable and scalable applications but now the book takes you down a path few Java developers dare to venture on, and that is into the world of RAD development with InternetBeans Express.
InternetBeans Express is a RAD (Rapid Application Development) framework that integrates into the JBuilder IDE. While I have never used this particular tool it does sound a lot like Uncle Bill's little tool/framework called .Net and Visual Studio in that it is not a front controller framework but instead the Page Controller version. The code that is shown in developing the sample app is very scary (you have been warned!) however it is a shame that the author didn't provide maybe some screen shoots of the IDE because the true power in using a page controller-based framework is in the coupling of the IDE. Sounds bad? Well, not really. As stated in the book, RAD frameworks serve the wonderful purpose of building applications in a short period of time. I really appreciate some of the comments made by the author about problems with RAD tools but I don't want to revel too much. :)
Continuing on the book's path of evaluating frameworks, we now come to Velocity. Huh? I love Velocity and I personally need to start using it more as a templating tool because it is very good at what it does, being a templating tool, and not a framework. I don't really understand why the author chose to insert Velocity at the same level as WebWork, Struts and others. This is even more confusing considering that there is a chapter on best practices; maybe they should state that stand alone templating tools aren't "best practices".
There truly are some gems in the book; you just have to spend the time finding them. One of those gems is the clarification of XML publishing frameworks (although the book does not distinguish it as XML). There are other publishing frameworks that are not XML-driven and these lean more towards CMS-ish web frameworks. This is discussed in the chapter on Cocoon, and while I'm not a big fan of Cocoon, the book does give some compelling reasons to consider a publishing-based web framework. It has been awhile since I last used Cocoon and after reading this chapter I think it is going to be a little while longer until I check it out again. When the author mentions that Action failures return nulls or that there are tons of commented out sections of code in the source code, I think 'hmmm, yellow flag.'
The last chapter of Part II reviews methods and strategies for evaluating a framework, which in a nutshell are:
- Does it fit the design of the application
- Time-to-market (light weight vs. heavy vs. RAD)
- Source code
- The Community
The book also goes into other considerations like architecture design, flexibility and a few others. While I don't agree with everything the author says in the chapter I can agree on the criteria offered to those who need to evaluate other frameworks.
Part III Best Practices
The topics covered in this section are:
- Separation of responsibilities (an in depth look at MVC)
- Flow control
- Resource Management
- Unit Testing
- Web Services
Some of the chapters provide helpful insight on how to solve common web application problems like page scrolling and undo functions. The solutions are very generic and therefore not tied to any one web framework, so the principles hopefully carry over to the framework of your choice. The chapter on Performance and Resource Management had me both crying in joy and yelling in anger, because it gives great detail to all the authors of web frameworks or those evaluating web frameworks of things to look out for like object pooling, garbage collection, object reuse; however, that is a small percentage of the users out there. These sections will act as a great resource for me as I further analyze the popular web frameworks out there except for the sections on profiling, which left me sick. The brief mention of JMeter is great while the absence of JUnitPerf and the choice to even explain the SDK profiler was painful.
The chapters on Debugging and Unit testing were interesting. They start off with a wonderful example of how and why you should not put logic in the JSP, but instead use tried and tested custom tags. While the code shown is useless to the readers, it does make an indirect point to never do this. For those who enjoy a little salt in your cuts, the books goes into detail on how to use the debugger that comes with Java. Luckily, for us mortals, it also reviews using the JBuilder and Netbeans debuggers; however, it is unfortunate that the more popular Eclipse and Intellij were not selected for discussion.
If the chapter on debugging left a sour taste in your mouth well open up for something more refreshing on Unit Testing. Unit Testing is sort of like teenage sex life, everyone is talking about it but no one is doing it so anytime I see another intro article I jump for joy and hope for more new comers after they read it. It is unfortunate that this chapter doesn't discuss how to implement Unit Testing with web frameworks. This is important because due to the various ways each of the web frameworks are implemented, some are easy to unit test while others are very painful. WebWork should have been spotlighted in this section for its beauty and elegance at Unit testing.
I find it great to have books out there to help inform users and developers of alternative frameworks to the assumed standard out there. In 'The Art of Java Web Development', the history and reasoning of why one should use a web framework was good along with the concept of having a sample application reproduced in all of the reviewed frameworks. I think this is important, having learned that lesson myself from doing the very same thing on the Wafer Project. While I felt that some of the frameworks chosen were of lesser interest to the community, it would have been nice to have replaced one of those dying frameworks with say ASP.NET (but that would go against the title of the book). Also, the layout of the book was confusing, in that Velocity was explained at the same level as Struts.
It's where the rubber meets the road where I differ with the author, yet most of my complaints merely pertained to layout, topic choice and style, so I guess it is different strokes for different folks. Overall, a book like this has been needed for quite sometime because it is nearly impossible for even the active consultant to stay current on all the latest frameworks and techniques in web development. By reading this book the reader will gain a broader knowledge of the choices in web frameworks they have today, and the tools for selecting the right framework for their project.
About the Author
Kris Thompson is the lead of a local Java user group, www.frameworks-boulder.org in Boulder Colorado that focuses solely on web frameworks and is also a contributor on the Expresso framework and Wafer project and author of other framework articles. You can email Kris at firstname.lastname@example.org.