Java Reference
In-Depth Information
It is a logical step that we should try to achieve the same goals for class structures that we at-
tempted for source code. We want to reuse good bits of work, and we want to enable others to
understand what we have done.
At the level of class structures, both these goals can be served by using design patterns. A de-
sign pattern describes a common problem that occurs regularly in software development and
then describes a general solution to that problem that can be used in many different contexts.
For software design patterns, the solution is typically a description of a small set of classes and
their interactions.
Design patterns help in our task in two ways. First, they document good solutions to problems
so that these solutions can be reused later for similar problems. The reuse in this case is not at
the level of source code, but at the level of class structures.
Second, design patterns have names and thus establish a vocabulary that helps software design-
ers talk about their designs. When experienced designers discuss the structure of an application,
one might say, “I think we should use a Singleton here.” Singleton is the name of a widely
known design pattern, so if both designers are familiar with the pattern, being able to talk about
it at this level saves explanation of a lot of detail. Thus, the pattern language introduced by
commonly known design patterns introduces another level of abstraction, one that allows us to
cope with complexity in ever-more-complex systems.
Software design patterns were made popular by a book published in 1995 that describes a set
of patterns, their applications, and benefits. 5 This topic is still today one of the most important
works about design patterns. Here, we do not attempt to give a complete overview of design
patterns. Rather, we discuss a small number of patterns to give readers an impression of the
benefits of using design patterns, and then we leave it up to the reader to continue the study of
patterns in other literature.
13.7.1
Structure of a pattern
Descriptions of patterns are usually recorded using a template that contains some minimum
information. A pattern description is not only information about a structure of some classes, but
also includes a description of the problem(s) this pattern addresses and competing forces for or
against use of the pattern.
A description of a pattern includes at least:
a name that can be used to conveniently talk about the pattern
a description of the problem that the pattern addresses (often split into sections such as
intent , motivation , and applicability )
a description of the solution (often listing structure , participants , and collaborations )
the consequences of using the pattern, including results and trade-offs
In the following section, we shall briefly discuss some commonly used patterns.
5
Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm,
Ralph Johnson, and John Vlissides, Addison-Wesley, 1995.
Search WWH ::




Custom Search