Being an expert programmer requires the ability to discover and apply patterns. Design patterns are strategies that provide reusable solutions for recurring problems. Patterns are useful for improving the extensibility and flexibility of software systems, isolating code changes, and providing a vocabulary for communication among developers.
This tutorial book presents the object-oriented design and programming patterns described in the flagship text [1], and shows how to use these patterns in Java programs. The book consists of six sections and includes a CD-ROM containing the Java code along with Unified Modeling Language (UML) diagrams for the program examples.
The first section defines the concept of design patterns and illustrates it with the model-view-controller framework. Three types of patterns are identified: creational, structural, and behavioral.
The second section presents six creational patterns: factory, factory method, abstract factory, singleton, builder, and prototype. The third section covers seven structural patterns: adapter, bridge, composite, decorator, facade, flyweight, and proxy. The fourth section describes 11 behavioral patterns: chain of responsibility, command, interpreter, iterator, mediator, memento, observer, state, strategy, template, and visitor. Each pattern is illustrated by at least one visual Java program example, and for each example there is a complete program on the CD-ROM. Most chapters conclude with a set of “thought questions” that ask the reader to recognize and apply patterns.
The fifth section describes the main classes of the Java Foundation Classes (JFCs). These classes are used in the examples throughout the preceding sections. The design patterns used by JFCs are highlighted in this section.
The final section discusses three case studies of applying design patterns. Unfortunately, the case studies are rather shallow, and page 310 contains a reference to the nonexistent figure number 34.3. Generally, it is regrettable that the book contains many typographical errors and poorly indented code fragments.
Despite these drawbacks, those who are conversant in Java will find this book useful for learning the essentials about patterns. The reason for this is threefold. First, the book gives a clear and well-written description of the common object-oriented design patterns. Second, it takes a practical approach, providing instructive Java programs for each design pattern. Third, it provides UML class diagrams for the Java programs, facilitating understanding of the interactions between the classes.