Summary
Capturing the wealth of experience about the design of object-oriented software, these four top-notch authors show how object-oriented systems exhibit recurring patterns and structures of objects that solve particular design problems, allowing designers to reuse successful designs and architectures without having to rediscover the design solutions. Central to this book is a catalog of 23 design patterns that have seen successful practical application and are representative of good object-oriented design. Each pattern describes the circumstances in which it is applicable, when it can be applied in view of other design constraints, and the consequences and tradeoffs of using the pattern in a larger design. Finally, every pattern includes code that shows how it may be implemented in object-oriented programming languages like C++ and Smalltalk.
Author Biography
Dr. Erich Gamma is technical director at the Software Technology Center of Object Technology International in Zurich, Switzerland. Dr. Richard Helm is a member of the Object Technology Practice Group in the IBM Consulting Group in Sydney, Australia. Dr. Ralph Johnson is a faculty member at the University of Illinois at Urbana-Champaign's Computer Science Department.
John Vlissides is a member of the research staff at the IBM T. J. Watson Research Center in Hawthorne, New York. He has practiced object-oriented technology for more than a decade as a designer, implementer, researcher, lecturer, and consultant. In addition to co-authoring Design Patterns: Elements of Reusable Object-Oriented Software, he is co-editor of the book Pattern Languages of Program Design 2 (both from Addison-Wesley). He and the other co-authors of Design Patterns are recipients of the 1998 Dr. Dobb's Journal Excellence in Programming Award.
0201633612AB09122003
Table of Contents
Preface |
|
xi | (2) |
Foreword |
|
xiii | (2) |
Guide to Readers |
|
xv | |
|
|
1 | (32) |
|
1.1 What Is a Design Pattern? |
|
|
2 | (2) |
|
1.2 Design Patterns in Smalltalk MVC |
|
|
4 | (2) |
|
1.3 Describing Design Patterns |
|
|
6 | (2) |
|
1.4 The Catalog of Design Patterns |
|
|
8 | (1) |
|
1.5 Organizing the Catalog |
|
|
9 | (2) |
|
1.6 How Design Patterns Solve Design Problems |
|
|
11 | (17) |
|
1.7 How to Select a Design Pattern |
|
|
28 | (1) |
|
1.8 How to Use a Design Pattern |
|
|
29 | (4) |
|
2 A Case Study: Designing a Document Editor |
|
|
33 | (46) |
|
|
33 | (2) |
|
|
35 | (5) |
|
|
40 | (3) |
|
2.4 Embellishing the User Interface |
|
|
43 | (4) |
|
2.5 Supporting Multiple Look-and-Feel Standards |
|
|
47 | (4) |
|
2.6 Supporting Multiple Window Systems |
|
|
51 | (7) |
|
|
58 | (6) |
|
2.8 Spelling Checking and Hyphenation |
|
|
64 | (12) |
|
|
76 | (3) |
Design Pattern Catalog |
|
79 | (280) |
|
|
81 | (54) |
|
|
87 | (10) |
|
|
97 | (10) |
|
|
107 | (10) |
|
|
117 | (10) |
|
|
127 | (8) |
|
Discussion of Creational Patterns |
|
|
135 | (2) |
|
|
137 | (82) |
|
|
139 | (12) |
|
|
151 | (12) |
|
|
163 | (12) |
|
|
175 | (10) |
|
|
185 | (10) |
|
|
195 | (12) |
|
|
207 | (12) |
|
Discussion of Structural Patterns |
|
|
219 | (2) |
|
|
221 | (124) |
|
|
223 | (10) |
|
|
233 | (10) |
|
|
243 | (14) |
|
|
257 | (16) |
|
|
273 | (10) |
|
|
283 | (10) |
|
|
293 | (12) |
|
|
305 | (10) |
|
|
315 | (10) |
|
|
325 | (6) |
|
|
331 | (14) |
|
Discussion of Behavioral Patterns |
|
|
345 | (6) |
|
|
351 | (8) |
|
6.1 What to Expect from Design Patterns |
|
|
351 | (4) |
|
|
355 | (1) |
|
6.3 The Pattern Community |
|
|
356 | (2) |
|
|
358 | (1) |
|
|
358 | (1) |
A Glossary |
|
359 | (4) |
B Guide to Notation |
|
363 | (6) |
B.1 Class Diagram |
|
363 | (1) |
B.2 Object Diagram |
|
364 | (2) |
B.3 Interaction Diagram |
|
366 | (3) |
C Foundation Classes |
|
369 | (6) |
C.1 List |
|
369 | (3) |
C.2 Iterator |
|
372 | (1) |
C.3 ListIterator |
|
372 | (1) |
C.4 Point |
|
373 | (1) |
C.5 Rect |
|
374 | (1) |
Bibliography |
|
375 | (8) |
Index |
|
383 | |
Excerpts
This book isn't an introduction to object-oriented technology or design. Many books already do a good job of that. This book assumes you are reasonably proficient in at least one object-oriented programming language, and you should have some experience in object-oriented design as well. You definitely shouldn't have to rush to the nearest dictionary the moment we mention "types" and"polymorphism," or "interface" as opposed to "implementation" inheritance.On the other hand, this isn't an advanced technical treatise either. It's a book of design patterns that describes simple and elegant solutions to specific problems in object-oriented software design. Design patterns capture solutions that have developed and evolved over time. Hence they aren't the designs people They reflect untold redesign and recoding as developers have struggled for greater reuse and flexibility in their software.Design patterns capture these solutions in a succinct and easily applied form.The design patterns require neither unusual language features nor amazing programming tricks with which to astound your friends and managers. All can be implemented in standard object-oriented languages, though they might take a little more work than ad hoc solutions. But the extra effort invariably pays dividends in increased flexibility and reusability.Once you understand the design patterns and have had an "Aha!" (and not just a "Huh?") experience with them, you won't ever think about object-oriented design in the same way. You'll have insights that can make your own designs more flexible, modular, reusable, and understandable - which is why you're interested in object-oriented technology in the first place, right?A word of warning and encouragement: Don't worry if you don't understand this book completely on the first reading. We didn't understand it all on the first writing! Remember that this isn't a book to read once and put on a shelf. We hope you'll find yourself referring to it again and again for design insights and for inspiration.This book has had a long gestation. It has seen four countries, three of its authors' marriages, and the birth of two (unrelated) offspring.Many people have had a part in its development. Special thanks are due Bruce Andersen, Kent Beck, and Andre Weinand for their inspiration and advice. We also thank those who reviewed drafts of the manuscript: Roger Bielefeld, Grady Booch, Tom Cargill, Marshall Cline, Ralph Hyre, Brian Kernighan, Thomas Laliberty, Mark Lorenz, Arthur Riel, Doug Schmidt, Clovis Tondo, Steve Vinoski, and Rebecca Wirfs-Brock. We are also grateful to the team at Addison-Wesley for their help and patience: Kate Habib, Tiffany Moore, Lisa Raffaele, Pradeepa Siva, and John Wait. Special thanks to Carl Kessler, Danny Sabbah, and Mark Wegman at IBM Research for their unflagging support of this work.Last but certainly not least, we thank everyone on the Internet and points beyond who commented on versions of the patterns, offered encouraging words, and told us that what we were doing was worthwhile. These people include but are not limited to Ran Alexander, Jon Avotins, Steve Berczuk, Julian Berdych, Matthias Bohlen, John Brant, Allan Clarke, Paul Chisholm, Jens Coldewey, Dave Collins, Jim Coplien, Don Dwiggins, Gabriele Elia, Doug Felt, Brian Foote, Denis Fortin, Ward Harold, Hermann Hueni, Nayeem Islam, Bikramjit Kalra, Paul Keefer, Thomas Kofler, Doug Lea, Dan LaLiberte, James Long, Ann Louise Luu, Pundi Madhavan, Brian Marick, Robert Martin, Dave McComb, Carl McConnell, Christine Mingins, Hanspeter Mossenbock, Eric Newton, Marianne Ozcan, Roxsan Payette, Larry Podmolik, George Radin, Sita Ramakrishnan, Russ Ramirez, Dirk Riehle, Bryan Rosenburg, Aamod Sane, Duri Schmidt, Robert Seidl, Xin Shu, and Bill Walker.We don't consider this collection of design patterns complete and static; it's more a recording of our current thoughts on design. We welcome comments on it, whether criticisms of our exa