
Classifying Relationships Between Object-Oriented Design Patterns James Noble Microsoft Research Institute Macquarie University Sydney, Australia [email protected] Abstract ing its own idiomatic classification of these relation- ships. This inconsistency can make patterns difficult Since the publication of the Design Patterns book, to use, because a pattern’s relationships to other pat- a large number of object-oriented design patterns terns is an important part of a pattern’s definition, and have been identified and codified. As part of the pat- inconsistent definitions make it difficult for readers to tern form, object-oriented design patterns must indi- understand the relationships intended by any particu- cate their relationships with other patterns, but these lar description. relationships are typically described very briefly, and In this paper, we present a classification scheme different collections of patterns describe different re- for the relationships between design patterns. This lationships in different ways. In this paper we de- scheme is based on three primary relationships be- scribe and classify the common relationships between tween patterns — a pattern uses another pattern, a pat- object oriented design patterns. Practitioners can use tern refines another pattern, or a pattern conflicts with these relationships to help them identity those pat- another pattern. The paper also describes a number of terns which may be applicable to a particular prob- secondary relationships between patterns, such as a lem, and pattern writers can use these relationships pattern being similar to another pattern, or one pattern to help them integrate new patterns into the body of combining with another pattern, and shows how these the patterns literature. secondary relationships can be expressed in terms of the primary relationships. This paper is organised as follows. Section 2 1. Introduction briefly reviews object-oriented design patterns and the major constituents of the pattern form. Section 3 de- scribes the structure of our classification scheme, and A design pattern is a “description of communicat- enumerates the relationships we describe. Section 4 ing objects and classes that are customised to solve a then presents the primary relationships in our classifi- general design problem in a particular context” [12, cation scheme in detail, and Section 5 describes how p.3]. Designers can incorporate patterns into their the secondary relationships between patterns can be program to address general problems in the structure expressed in terms of the primary relationships. Sec- of their programs’ designs, in a similar way that al- tion 6 concludes the paper. gorithms or data structures are incorporated into pro- grams to solve particular computational or storage problems. A growing body of literature catalogues 2. Object-Oriented Design Patterns patterns for object-oriented design, including refer- ence texts such as Design Patterns [12] or Patterns A design pattern is an abstraction from a con- of Software Architecture [5], and patterns compendia crete recurring solution that solves a problem in a such as the Pattern Languages of Program Design se- certain context [12, 5]. Design patterns were devel- ries [6, 28, 17]. oped by an architect, Christopher Alexander, to de- Design patterns do not stand alone — rather each scribe techniques for town planning, architectural de- pattern is related other patterns in a variety of ways, signs, and building construction techniques and de- and the text of each pattern should describe these re- scribed in Alexander’s A Pattern Language Towns, lationships. Unfortunately, each pattern text book or Building Construction [1]. Design patterns were first catalogue describes relationships between patterns us- applied to software by Kent Beck and Ward Cunning- 1 ham to describe user interface design techniques [4], sification scheme for relationships between patterns and were then popularised by the Design Patterns cat- presented in this paper was developed to support the alogue, which described twenty-three general purpose wider goal of organising patterns in the Found Ob- patterns for object oriented design. Since Design Pat- jects project, by identifying the most important rela- tern’s publication, a large number of other patterns tionships between patterns. have been identified and published [5, 3, 2, 6, 28, 17]. More recently, different types of patterns have been 3. Classifying Relationships between identified, including Composite Patterns [25] and Pat- tern Tilings [14]. Patterns A design pattern is written in pattern form, that is Figure 1 illustrates the structure of our classifica- in one of a family of literary styles designed to make tion scheme for relationships between patterns. The patterns easy to apply. A design pattern has a name classification scheme is based on three primary re- to facilitate communication about programs in terms lationships between patterns — one pattern uses an- of patterns, a description of the problems for which other pattern; a more specific pattern refines a more the pattern is applicable, an analysis of the forces ad- general pattern, and one pattern conflicts with another dressed by the pattern and the important considera- pattern when they both propose solutions to a similar tions and consequences of using the pattern, a sam- problem. These three relationships are described in ple implementation of the pattern’s solution, and ref- Section 4. erences to known uses of the pattern. The scheme also describes a number of secondary Most importantly from the perspective of this pa- relationships between patterns, such as a pattern be- per, a pattern lists other patterns which are in some ing a variant of another pattern, two patterns being way related. The problem addressed by this paper is similar, or two patterns combining to solve a prob- that different collections of patterns describe different lem. Section 5 presents the secondary relationships, relationships between patterns in different ways. For and describes how they can be expressed in terms of example, the relationships between object-oriented the primary relationships. design patterns were first analysed by Walter Zimmer, who studied the relationships between patterns in De- sign Patterns[12]. According to Zimmer [31], there 4. Primary Relationships are three relationships — one pattern can use another pattern; a variant of one pattern can use another pat- Our classification scheme is based on three pri- tern; and one pattern can be similar to another pattern. mary relationships between patterns — uses, refines, The Design Patterns Smalltalk Companion includes and conflicts. In this section we outline these three re- these three relationships, but introduces a fourth re- lationships, present examples of well-known patterns lationship — one pattern can be a specialisation of which exhibit these relationships, and provide a sim- another pattern [2]. Patterns of Software Architec- ple graphical notation which can illustrate these rela- ture describes three kinds of relationships between tionships between groups of patterns. patterns, including Zimmer’s first relationship and in- troducing two more — one pattern can be a variant 4.1. Uses of another pattern; and two patterns can be used in combination to solve a problem [5]. Meszaros and Almost every pattern form records the patterns Doble’s Patterns for Pattern Writing [18] identify five which each pattern uses — that is, patterns which relationships between patterns — a pattern can use, be help another pattern. Typically, a pattern which has used by, generalise, specialise, or provide an alterna- a larger or more global impact on a design will use tive to another pattern. Other patterns or collections of patterns which have smaller or more local impacts. patterns describe other relationships between patterns The uses relationship is the only explicit relation- and recent work has discussed compositional and re- ship between patterns in Alexander’s original archi- flexive relationships between patterns [27, 25, 14]. tectural patterns [1]. Alexander’s patterns are organ- We are engaged in a long-term project called ised into a pattern language based on this relation- “Found Objects” that aims to organise patterns for ship — that is, the patterns are organised so that each object-oriented design [19, 20, 21, 23]. As part of pattern is followed by the other smaller-scale patterns this project, we have analysed existing patterns to de- which it uses, and which should be considered once termine their relationships to other patterns. We have the large-scale pattern has been chosen. For example, identified new patterns, and then related these patterns the Small Public Squares pattern uses the Pedestrian to the existing patterns in the literature. The clas- Density, Activity Pockets, and Something Roughly in 2 Primary Relationships Uses One pattern uses another pattern [1, 12, 31] Refines A specific pattern refines a general pattern [2, 18] Conflicts A pattern addresses the same problem as another pattern [8, 3] Secondary Relationships Used by A smaller pattern is used by a larger pattern [1] Refined by A general pattern is refined by a specific pattern [18] Variant A variant pattern refines a more well-known pattern [5] Variant Uses A variant of one pattern uses another pattern [31] Similar A pattern is similar to another pattern [31] Combines Two patterns combine to solve a single problem [5, 8] Requires A pattern requires the solution of another pattern [7] Tiling A pattern uses itself [14] Sequence of A sequence of patterns from the simple to the complex [26, 11] Elaboration Figure 1. The Structure of the Classification Scheme the Middle patterns. The Small Public Squares pattern describe how these patterns are combined into the is a larger scale pattern because it describes the design composite pattern, for example, by using role dia- of the entire square; the other patterns are smaller be- grams [25]. Following Zimmer [31], Figure 2 shows cause they describe the pedestrian traffic in the square, how the structure of uses relationships can be illus- the edges of the square, and the centre of the square trated graphically. respectively.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages10 Page
-
File Size-