“...
describes a problem which occurs over and over again in our environment, and
then describes the core of the solution to that problem, in such a way that you
can use this solution a million times over, without ever doing it the same way
twice” – Christopher Alexander
This
chapter introduces the important and yet non-traditional “patterns”
approach to program design.
[[
Much of the prose in this chapter still needs work, but the examples all
compile. Also, more patterns and examples are forthcoming ]]
Probably
the most important step forward in object-oriented design is the “design
patterns” movement, chronicled in Design
Patterns
,
by Gamma, Helm, Johnson & Vlissides (Addison-Wesley 1995).
[64]
That book shows 23 different solutions to particular classes of problems. In
this chapter, the basic concepts of design patterns will be introduced along
with examples. This should whet your appetite to read
Design
Patterns
(a source of what has now become an essential, almost mandatory, vocabulary for
OOP programmers).
The
latter part of this chapter contains an example of the design evolution
process, starting with an initial solution and moving through the logic and
process of evolving the solution to more appropriate designs. The program shown
(a trash recycling simulation) has evolved over time, and you can look at that
evolution as a prototype for the way your own design can start as an adequate
solution to a particular problem and evolve into a flexible approach to a class
of problems.