| |
| |
Foreword | |
| |
| |
Preface | |
| |
| |
| |
Introduction to Patterns | |
| |
| |
Why Patterns? | |
| |
| |
Why Design Patterns? | |
| |
| |
Why Java? | |
| |
| |
Why UML? | |
| |
| |
Why a Workbook? | |
| |
| |
The Organization of This Book | |
| |
| |
Welcome to Oozinoz! | |
| |
| |
Source Code Disclaimer | |
| |
| |
Summary | |
| |
| |
| |
Interface Patterns | |
| |
| |
| |
Introducing Interfaces | |
| |
| |
Ordinary Interfaces | |
| |
| |
Interfaces and Obligations | |
| |
| |
Placing Constants in Interfaces | |
| |
| |
Summary | |
| |
| |
Beyond Ordinary Interfaces | |
| |
| |
| |
Adapter | |
| |
| |
Adapting in the Presence of Foresight | |
| |
| |
Class and Object Adapters | |
| |
| |
Unforeseen Adaptation | |
| |
| |
Recognizing Adapter | |
| |
| |
Summary | |
| |
| |
| |
Facade | |
| |
| |
Refactoring to Facade | |
| |
| |
Facades, Utilities, and Demos | |
| |
| |
Summary | |
| |
| |
| |
Composite | |
| |
| |
An Ordinary Composite | |
| |
| |
Recursive Behavior in Composites | |
| |
| |
Trees in Graph Theory | |
| |
| |
Composites with Cycles | |
| |
| |
Consequences of Cycles | |
| |
| |
Summary | |
| |
| |
| |
Bridge | |
| |
| |
A Classic Example of Bridge: Drivers | |
| |
| |
Refactoring to Bridge | |
| |
| |
A Bridge Using the List Interface | |
| |
| |
Summary | |
| |
| |
| |
Responsibility Patterns | |
| |
| |
| |
Introducing Responsibility | |
| |
| |
Ordinary Responsibility | |
| |
| |
Controlling Responsibility with Visibility | |
| |
| |
Summary | |
| |
| |
Beyond Ordinary Responsibility | |
| |
| |
| |
Singleton | |
| |
| |
Singleton Mechanics | |
| |
| |
Singletons and Threads | |
| |
| |
Recognizing Singleton | |
| |
| |
Summary | |
| |
| |
| |
Observer | |
| |
| |
A Classic Example: Observer in Swing | |
| |
| |
Model/View/Controller | |
| |
| |
Maintaining an Observable Object | |
| |
| |
Summary | |
| |
| |
| |
Mediator | |
| |
| |
A Classic Example: GUI Mediators | |
| |
| |
Relational Integrity Mediators | |
| |
| |
Summary | |
| |
| |
| |
Proxy | |
| |
| |
A Classic Example: Image Proxies | |
| |
| |
Image Proxies Reconsidered | |
| |
| |
Remote Proxies | |
| |
| |
Summary | |
| |
| |
| |
Chain of Responsibility | |
| |
| |
Varieties of Lookup | |
| |
| |
Refactoring to Chain of Responsibility | |
| |
| |
Anchoring a Chain | |
| |
| |
Chain of Responsibility without Composite | |
| |
| |
Summary | |
| |
| |
| |
Flyweight | |
| |
| |
Recognizing Flyweight | |
| |
| |
Immutability | |
| |
| |
Extracting the Immutable Part of a Flyweight | |
| |
| |
Sharing Flyweights | |
| |
| |
Summary | |
| |
| |
| |
Construction Patterns | |
| |
| |
| |
Introducing Construction | |
| |
| |
Ordinary Construction | |
| |
| |
Superclass Collaboration | |
| |
| |
Collaboration within a Class | |
| |
| |
Summary | |
| |
| |
Beyond Ordinary Construction | |
| |
| |
| |
Builder | |
| |
| |
Building from a Parser | |
| |
| |
Building under Constraints | |
| |
| |
Building a Counteroffer | |
| |
| |
Summary | |
| |
| |
| |
Factory Method | |
| |
| |
Recognizing Factory Method | |
| |
| |
A Classic Example of Factory Method: Iterators | |
| |
| |
Taking Control of Which Class to Instantiate | |
| |
| |
Factory Method in Parallel Hierarchies | |
| |
| |
Summary | |
| |
| |
| |
Abstract Factory | |
| |
| |
Abstract Factories for Families of Objects | |
| |
| |
Packages and Abstract Factories | |
| |
| |
Abstract Factories for Look-and-Feel | |
| |
| |
Summary | |
| |
| |
| |
Prototype | |
| |
| |
Prototypes as Factories | |
| |
| |
Prototyping with Clones | |
| |
| |
Using Object.clone() | |
| |
| |
Summary | |
| |
| |
| |
Memento | |
| |
| |
Memento Durability | |
| |
| |
Applying Memento | |
| |
| |
Persisting Mementos across Sessions | |
| |
| |
Using Strings as Mementos | |
| |
| |
Summary | |
| |
| |
| |
Operation Patterns | |
| |
| |
| |
Introducing Operations | |
| |
| |
Operations, Methods, and Algorithms | |
| |
| |
The Mechanics of Methods | |
| |
| |
Exceptions in Methods | |
| |
| |
Summary | |
| |
| |
Beyond Ordinary Operators | |
| |
| |
| |
Template Method | |
| |
| |
A Classic Example of Template Method: Sorting | |
| |
| |
Completing an Algorithm | |
| |
| |
Template Method Hooks | |
| |
| |
Refactoring to Template Method | |
| |
| |
Summary | |
| |
| |
| |
State | |
| |
| |
Modeling States | |
| |
| |
Refactoring to State | |
| |
| |
Making States Constant | |
| |
| |
Summary | |
| |
| |
| |
Strategy | |
| |
| |
Modeling Strategies | |
| |
| |
Refactoring to Strategy | |
| |
| |
Comparing Strategy and State | |
| |
| |
Comparing Strategy and Template Method | |
| |
| |
Summary | |
| |
| |
| |
Command | |
| |
| |
A Classic Example: Menu Commands | |
| |
| |
Using Command to Supply a Service | |
| |
| |
Command in Relation to Other Patterns | |
| |
| |
Summary | |
| |
| |
| |
Interpreter | |
| |
| |
An Interpreter Example | |
| |
| |
Interpreters, Languages, and Parsers | |
| |
| |
Summary | |
| |
| |
| |
Extension Patterns | |
| |
| |
| |
Introducing Extensions | |
| |
| |
Reuse as an Alternative to Extension | |
| |
| |
Extending by Subclassing | |
| |
| |
The Liskov Substitution Principle | |
| |
| |
Extending by Delegating | |
| |
| |
Summary | |
| |
| |
Beyond Ordinary Extension | |
| |
| |
| |
Decorator | |
| |
| |
A Classic Example of Decorator: Streams | |
| |
| |
Function Decorators | |
| |
| |
Decorating without Decorator | |
| |
| |
Summary | |
| |
| |
| |
Iterator | |
| |
| |
Type-Safe Collections | |
| |
| |
Iterating Over a Composite | |
| |
| |
Thread-Safe Iterators | |
| |
| |
Summary | |
| |
| |
| |
Visitor | |
| |
| |
Supporting Visitor | |
| |
| |
Extending with Visitor | |
| |
| |
Visitor Cycles | |
| |
| |
Visitor Controversy | |
| |
| |
Summary | |
| |
| |
| |
Appendixes | |
| |
| |
| |
Directions | |
| |
| |
| |
Solutions | |
| |
| |
| |
UML at a Glance | |
| |
| |
Glossary | |
| |
| |
Bibliography | |
| |
| |
Index | |