Books by author: Erich Gamma

Design Patterns

by Erich Gamma and Richard Helm and Ralph Johnson and John Vlissides

Addison-Wesley (395 pages)
Keyword(s): Nonfiction, Programming
Dates read: January 30 - February 01, 2004, Rating: *****

I had glanced through this book several times starting about three years ago, but have only now managed to read it from cover to cover. Object-orientation (OO) is a very specific mindset for programming — one that does not always come easily for those who were steeped in procedural programming for decades (I started programming around 1980). For simple applications, OO is overkill, but it can make complex systems managable, in large part by compartmentalizing the data representations into units whose structure maps naturally onto the problem domain.

As one gains experience with OO systems, patterns (similar sets of relationships among objects) begin to become apparent in designs, and the more readily one can recognize the appropriate places to apply these patterns, the more quickly a reasonable design can be fashioned. This book collects twenty-three such patterns, divided into three groups (five creational, seven structural, and eleven behavioral). Each pattern is discussed in great detail, with several standard section headings: intent (executive soundbite), also known as (other names for the pattern), motivation (why the pattern is a good idea) applicability (situations that merit its use), structure (a diagram showing a high-level view of how it works), participants (a brief functional description of the objects in the diagram), collaborations (other patterns that are closely related), consequences (some possible gotchas), implementation (some things to keep in mind when writing the code), and sample code (in C++ and smalltalk). The book also contains a useful reference table in the front bookend and a couple of useful appendices.

One important thing to keep in mind is that Design Patterns is not a step-by-step exposition, and it's not meant to be absorbed in one pass. It's a reference book, and the intent is that the reader should become familiar enough with the twenty-three patterns it contains that when a particular pattern would be useful in a design, he can quickly find the relevant details and refresh his memory. It also serves to add a bunch of useful terms to the programmer's lexicon, thereby facilitating communication of complex ideas between programmers.

The bottom line is that Design Patterns is a classic programming text, and it should probably be on the desk of all but the most guru-ish OO gods.