Design Patterns: Abstraction and Reuse ofOb ject-Oriented DesignErichGamma1?,Richard Helm2, Ralph Johnson3, John Vlissides21Taligent, Inc.10725 N. De Anza Blvd., Cup ertino, CA 95014-2000 USA2I.B.M. Thomas J. Watson Research CenterP.O. Box 704, Yorktown Heights, NY 10598 USA3Department of Computer ScienceUniversity of Illinois at Urbana-Champaign1034 W. Springeld Ave., Urbana, IL 61801 USAAbstract.We prop osedesign patternsas a new mechanism for expressing ob ject-orienteddesign experience. Design patterns identify, name, and abstract common themes in ob ject-oriented design. They capture the intent behind a design byidentifying ob jects, their col-laborations, and the distribution of resp onsibili ties. Design patterns play many roles in theob ject-oriented development process: they provide a common vocabulary for design, they re-duce system complexityby naming and dening abstractions, they constitute a base of ex-perience for buildin g reusable software, and they act as building blo cks from which morecomplex designs can b e built. Design patterns can be considered reusable micro-architecturesthat contribute to an overall system architecture. We describ e how to express and organizedesign patterns and introduce a catalog of design patterns. We also describ e our exp erience inapplying design patterns to the design of ob ject-oriented systems.1 Intro ductionDesign methods are supposed to promote goo d design, to teach new designers how to design well, andto standardize the way designs are developed. Typically, a design metho d comprises a set of syntacticnotations (usually graphical) and a set of rules that govern how and when to use each notation. Itwill also describe problems that o ccur in a design, howtoxthem,andhowtoevaluate a design.Studies of expert programmers for conventional languages, however, haveshown that knowledge isnot organized simply around syntax, but in larger conceptual structures such as algorithms, datastructures and idioms [1, 7, 9, 27], and plans that indicate steps necessary to fulll a particulargoal [26]. It is likely that designers do not think about the notation they are using for recordingthe design. Rather, they lo ok for patterns to match against plans, algorithms, data structures, andidioms they have learned in the past. Goo d designers, it appears, rely on large amounts of designexperience, and this experience is just as important as the notations for recording designs and therules for using those notations.Our experience with the design of object-oriented systems and frameworks [15,17,22, 30, 31]bears out this observation. Wehave found that there exist idiomatic class and ob ject structures thathelp make designs more exible, reusable, and elegant. For example, the Model-View-Controller(MVC) paradigm from Smalltalk [19] is a design structure that separates representation from pre-sentation. MVC promotes exibilityinthe choice of views, independent of the model. Abstractfactories [10] hide concrete subclasses from the applications that use them so that class names arenot hard-wired into an application.?Work performed while at UBILAB, Union Bank of Switzerland, Zurich, Switzerland.To app ear inECOOP '93 ConferenceProceedings, Springer-VerlagLecture Notes in Computer Science.Well-dened design structures like these have a p ositive impact on software development. Asoftware architect who is familiar with a go od set of design structures can apply them immediatelyto design problems without having to rediscover them. Design structures also facilitate the reuse ofsuccessful architectures|expressing proven techniques as design structures makes them more readilyaccessible to developers of new systems. Design structures can even improve the documentation andmaintenance of existing systems by furnishing an explicit specication of class and ob ject interactionsand their underlying intent.To this end we proposedesign patterns, a new mechanism for expressing design structures.Design patterns identify, name, and abstract common themes in ob ject-oriented design. They pre-serve design information by capturing the intent behind a design. They identify classes, instances,their roles, collaborations, and the distribution of resp onsibilities. Design patterns havemanyusesin the ob ject-oriented development pro cess:{Design patterns provide a common vocabulary for designers to communicate, do cument, andexplore design alternatives. They reduce system complexityby naming and dening abstractionsthat are ab ove classes and instances. A go od set of design patterns eectively raises the level atwhich one programs.{Design patterns constitute a reusable base of exp erience for building reusable software. Theydistill and provide a means to reuse the design knowledge gained by experienced practitioners.Design patterns act as building blocks for constructing more complex designs; they can beconsideredmicro-architecturesthat contribute to overall system architecture.{Design patterns help reduce the learning time for a class library. Once a library consumer haslearned the design patterns in one library, he can reuse this experience when learning a new classlibrary. Design patterns help a novice perform more like an exp ert.{Design patterns provide a target for the reorganization or refactoring of class hierarchies [23].Moreover, by using design patterns early in the lifecycle, one can avert refactoring at later stagesof design.The ma jor contributions of this paper are: a denition of design patterns, a means to describethem, a system for their classication, and most importantly, a catalog containing patterns wehavediscovered while building our own class libraries and patterns wehave collected from the literature.This work has its ro ots in Gamma's thesis [11], which abstracted design patterns from the ET++framework. Since then the work has been rened and extended based on our collective experience.Our thinking has also been inuenced and inspired by discussions within the Architecture Handb ookWorkshops at recent OOPSLA conferences [3, 4].This paper has two parts. The rst introduces design patterns and explains techniques to describethem. Next we present a classication system that characterizes common aspects of patterns. Thisclassication will serve to structure the catalog of patterns presented in the second part of this pap er.We discuss how design patterns impact object-oriented programming and design. We also reviewrelated
View Full Document