J2EE Design Patterns

William Crawford, Jonathan Kaplan (2003)
Review date: February, 2011
Summary

The introductory chapter is about patterns, the APIs comprising the J2EE stack, and some quality attributes (although they are called "core development concepts"). Chapter two gives a 20 page introduction to UML, which is sufficient, since the book doesn't make use of UML extensively.

Chapter three, "Presentation tier architecture", walks you through an example starting with MVC to evolve into a decorated (using filters) Front Controller. In the following chapter, the setup is further extended using Service To Worker, View Helper, and Composite View. In the last chapter devoted to the presentation tier, three patterns related to scalability are introduced: Asynchronous Page, Caching Filter, and Resource Pool.

Chapter six is a change of topic and discusses the business tier. It's a short chapter about what a business tier looks like and about domain models. The Composite Entity pattern is described here too. The next chapter is also very short and describes patterns for communication, the Data Transfer Object, the Data Transfer Hash, and Row Set DTO.

Database and Data Patterns is about the DAO and DAO factory pattern. It also describes some patterns related to the data timeliness and primary key generation. Towards the end of the chapter, there are some patterns related to situations that arise when O/R mappings are involved. Business Delegate and its corresponding factory, Service Adapter, Session Facade, and Service Locator are the dominant patterns of chapter nine.

Unlike many other books, this book pays some attention to concurrency through its tenth chapter. In this chapter the reader meets transactions, locking, and versioning. Most concepts are expressed as patterns.

The last technology-centric chapter, which is on messaging, contains a good overview of messaging in general, starting with simple mail (SMTP). From there, JMS gets a natural introduction. Patterns covered are: Publish-Subscribe, Malformed Message Channel, Sequenced Message, Content Aggregator, and Polling Consumer, to name a few.

The final chapter is on anti-patterns. It describes roughly six patterns that are quite specific to old J2EE implementations.

A dominating characteristic of this book is that it's not structured as a pattern catalog. Instead, all patterns are introduced gradually with extensive sample code.

Opinion

I wish every book on pattern was like this one! Instead of building a dry pattern catalog GoF style, the authors use a narrative and novel approach, where each chapter begins with some theory and background, after which the patterns are gradually introduced. Instead of emphasizing UML diagrams, the authors emphasize code. The book contains lots of code. From this point of view the book is absolutely superior in comparison to other pattern books. The background/problem/theory parts of the chapters are often good in themselves, and provide good introductions to the problem domains.

Ok, the book is absolutely amazing when introducing the patterns, what's bad then? Two things, of which one is a function of the time of this review.

In 2011, the contents of this book are unfortunately not very applicable. Given the way Java and JEE has evolved since this book was written, I'd say that 50% of it is obsolete. On the other hand, applications using these patterns and idioms are out there for maintenance, so knowing some old school solutions is not a bad thing.

The other flaw of this book is that it follows the "everything is a pattern" anti-pattern (excuse the phrasing; couldn't restrain myself). In the era of this book's birth, authors wanted to claim as many patterns as possible, so it's perfectly natural for this book to do the same.

Try these for size: the Resource Pool Pattern, the IsDirty Pattern, the Stored Procedures for Primary Keys Pattern, the Serialized Entity Pattern, the ACID Transaction Pattern, and the list goes on.

Now, technically all these are solutions to commonly recurring problems, hence patterns, but something about this disturbs me. To me, the ACID Transaction Pattern is equivalent to "the Main Function Pattern". Maybe that's just me. Nevertheless, if you accept that everything is a pattern, the book still discusses many useful techniques, and the authors display deep technical knowledge. All in all, if you're up against old legacy J2EE applications, this book will be your friend - the book on patterns pattern.

Who should read this book

If you're maintaining a legacy application written all in J2EE, this book might prove useful and give you some hints about the patterns and idioms used.




News

  • 2015-09-29

    It's been almost one and a half year since I reviwed a book! I've been too absorbed by Writing my own. Anyway, I'm back with Jeff Patton's relatively...
  • 2014-01-04

    New category! Performance! Reviewed The Every Computer Performance Book. Check it out!
  • 2013-09-10

    Reviewed a book that' slightly less technical, but much more fun to read. It's I.T. Confidential.
  • 2013-08-13

    Reviewed yet another book on Visual Studio 2012 and TFS. I also created a "Microsoft" category and moved the other TFS book there from the "Tools"...
  • 2013-08-05

    Updated the FAQ. Included information about getting a book reviewed.