Review: Holub on Patterns

21 December 2004

As you may know if you are a frequent reader of my weblog, I'm a huge fan of design patterns, so when APress offered to send me another couple books to review, I was greatly excited to get a chance to look at Allen Holub's Holub on Patterns: Learning Design Patterns by Looking at Code.

Overall Impression

As a patterns book, I already start out liking it much more than other types of books. The book is also very detailed with its examples and extended explanations of proper object-oriented methodologies, so that too scores bonus points with me.

The author admittedly starts out assuming you know most the good reasons to use aspects of object-oriented programming and detracts from that stance in his arguments against certain aspects. These practices include the blind use of accessors and mutators and implementation inheritance. I don't think I completely like this style, since it leaves me feeling sort of desperate for alternative practices by the end of a section. Despite saying he wasn't going to cover the Pros, he does visit that side of the coin long enough to explain the appropriate applications of our common practices at which he previously took aim.

I found myself often referring back to the Gang of Four book to see if they provided any of these caveats, but often they did not. Mr. Holub's valuable warnings developed from real experience with these patterns.

The book is sprinkled with typos and slight mis-wordings, but anyone familiar with the subject matter should be able to spot and compensate for the mistakes. I think they could be unnecessary stumbling blocks for the beginner though. (I have a slow word-for-word reading style which makes typos especially distracting.)

I've also never been a fan of anonymous inner classes, so I approach that little trick with skepticism. Mr. Holub uses them quite a bit, and when <<Anonymous>> creeps into the UML diagrams, I'm especially disenchanted with anonymous classes. I think normal named classes could be more descriptive for examples.

The Chapter Details

I found Chapters 1 and 2 packed with the most useful information. The extensive discussion of proper OO and common misconceptions really changed the way I coded -- I bid goodbye to my beloved Template Method pattern in favor of the Strategy pattern to break the fragile coupling of implementation inheritance. It was also good to see Java examples for the basics of factories, singletons, and discussions of their pitfalls.

Chapters 3 and 4 provided complete pattern examples by showing them entangled in working, large-scale examples (the Game of Life, and an Embedded SQL Database). These chapters effectively demonstrate the complexity with which these patterns often interact and enforced points made in the earlier chapters. I struggled and gave up at some parts trying to absorb everything here.

Each of these large chapters contains the complete project code for reference, so I ended up skipping 20 pages at a time while reading, but I know I'll find these pages useful when I need concrete examples of these pattern implementations. I'm pretty sure it was a good idea for the author to include this code.

The end of the book contains a complete catalog of all the Gang of Four patterns in an appendix. It consists of a concise 2 page summary devoted to each pattern, including bits of Java code. It also has references to well-known APIs which demonstrate the patterns. This appendix and the extensive discussions have earned this book its new place in my laptop bag replacing my old Gang of Four book.


The publisher printed this book in hardback signifying their belief that the book will be relevant for a while. I completely agree -- it relates and refines many years of experience in the object-oriented and pattern communities.

Filed Under: Java Work Books