Java Frameworks And Tools

Dr. Dobb's Journal December, 2004

By Laura MacDougall & Gregory V. Wilson

Laura, a software developer in Toronto, can be contacted at laura.macdougall@utoronto.ca. Greg is a DDJ contributing editor and can be contacted at gvwilson@ddj.com.

Tapestry in Action
Howard Lewis Ship
Manning, 2004
400 pp., $44.95
ISBN 1932394117

Better, Faster, Lighter Java
Bruce A. Tate and Justin Gehtland
O'Reilly & Associates, 2004
243 pp., $34.95
ISBN 0596006764

Tapestry is a component-based Java application framework (http://jakarta.apache.org/tapestry/) designed as a replacement for JSPs and servlets. If you're using it, or even just thinking about using it, Howard Ship's Tapestry In Action is an essential book to have. The copy we have in the office was passed back and forth as we all grappled our way up the learning curve—and it is still covered in post-it notes.

The book does an excellent job of providing straightforward examples and using language that is accessible to novices, then gradually working up to more advanced techniques. Chapter 2 is an excellent step-by-step introduction to building a simple Tapestry application, so it's a great place to get a feel for how Tapestry works. Chapters 3-6 cover all the important concepts for building Tapestry code, including using and creating components, handling forms, and validation. Chapters 7 and 8 explain how Tapestry handles the things you don't see on the outside, such as the page rendering process and the engine services. The last section takes you through designing and implementing a full Tapestry application, bringing everything together.

Of course, books are like software: They always contain at least a few bugs. In Tapestry In Action, the "simple, then more realistic" approach can be a trap because it's easy to read the section on "how to do X" in an early chapter and miss the "here's the real way to do X" section later on. Also, although the "in Action" series is designed to give you quick access to the information they need, this book's index leaves you pining for Google, with 20 separate listings under the heading "values," and none at all for such essential components as DirectLink and Select. Overall, though, resources for learning Tapestry are still scarce, so it's definitely worth the investment to have a copy for reference.

—L.M.

I sometimes think that Ecclesiastes must have been a programmer. "The thing that hath been, it is that which shall be...and there is no new thing under the sun." I don't know about you, but it sure reminds me of the never-ending debate between people who want comprehensive frameworks so that they can assemble applications out of tried and tested components, and those who want to keep their libraries light, agile, and (most importantly) comprehensible, even if it means building more of each application by hand.

Better, Faster, Lighter Java, by Bruce Tate and Justin Gehtland, is the latest salvo on this war's Java front. By now, most developers would agree that Enterprise JavaBeans (EJB) is a mess. As Tate and Gehtland point out, any system that requires you write half a dozen classes and XML deployment descriptors to implement a simple integer counter must have taken a wrong turn somewhere. The alternative they propose is certainly attractive: Hibernate (http://www.hibernate.org/) to persist POJOs (Plain Old Java Objects), and Spring (http://www.springframework.org/) as a container, are a fraction of the size of full-blown EJB, but can do most of the things that most programmers want most of the time.

But a book isn't just a point of view—it's a presentation of a point of view, and that's where this one left me unsatisfied. First, there were more paragraphs than I wanted on the future of the industry (they seem to feel that any company with more than a dozen employees is a swamp of self-serving hypocrisy), and too many motherhood-and-apple-pie statements about the virtues of simplicity and transparency. Simple in whose eyes? Transparent by what measure? I'm pretty sure the programmer they mock on page 17 thought his code was both...

The authors do much better when they get into the specific technical problems of EJB, and the ways in which lighter frameworks are better. However, once they start doing this, they aren't as critical of their favored alternative as they are of EJB. For example, five of my students at the University of Toronto have been working with Hibernate for the last four months. We definitely prefer it to JDO, or to rolling our own persistence layer, but we have still had to bend some of our data model out of shape to fit Hibernate's needs, and debugging mapping files is about as much fun as, well, debugging EJB deployment descriptors.

I came away from Better, Faster, Lighter Java feeling that the authors never made up their minds whether they were writing a polemic or a technical how-to. A little of one mixed into the other would have been fine, but the balancing act they seemed to be striving for just didn't work for me. Everything they discuss is worth knowing, but this book may not be the best way to pick it up.

—G.V.W.

DDJ