Page 208 -
P. 208
7.2 Design patterns 191
50
D
A
C 25
B 0 A B C D
Subject
A: 40
Observer 1 B: 25 Observer 2
Figure 7.11 Multiple C: 15
displays D: 20
pattern is one that is equally applicable to any kind of software design. So, you could
have configuration patterns for COTS systems. Patterns are a way of reusing the
knowledge and experience of other designers.
The four essential elements of design patterns were defined by the ‘Gang of Four’
in their patterns book:
1. A name that is a meaningful reference to the pattern.
2. A description of the problem area that explains when the pattern may be
applied.
3. A solution description of the parts of the design solution, their relationships, and
their responsibilities. This is not a concrete design description. It is a template
for a design solution that can be instantiated in different ways. This is often
expressed graphically and shows the relationships between the objects and
object classes in the solution.
4. A statement of the consequences—the results and trade-offs—of applying the
pattern. This can help designers understand whether or not a pattern can be used
in a particular situation.
Gamma and his co-authors break down the problem description into motivation
(a description of why the pattern is useful) and applicability (a description of situations
in which the pattern may be used). Under the description of the solution, they describe
the pattern structure, participants, collaborations, and implementation.
To illustrate pattern description, I use the Observer pattern, taken from the book
by Gamma et al. (Gamma et al., 1995). This is shown in Figure 7.10. In my descrip-
tion, I use the four essential description elements and also include a brief statement
of what the pattern can do. This pattern can be used in situations where different
presentations of an object’s state are required. It separates the object that must be
displayed from the different forms of presentation. This is illustrated in Figure 7.11,
which shows two graphical presentations of the same data set.
Graphical representations are normally used to illustrate the object classes in
patterns and their relationships. These supplement the pattern description and add