Design Patterns: Elements of Reusable Object-Oriented Software
392
arelikely to change during the life of the software, and a good designwill be
robust to them.
Our design patterns capture many of the structures that result fromrefactoring.
Using these patterns early in the life of a designprevents later refactorings.
But even if you don't see how to apply apattern until after you've built your
system, the pattern canstill show you how to change it. Design patterns thus provide
targetsfor your refactorings.
A Brief History
The catalog began as a part of Erich's Ph.D.thesis [Gam91, Gam92]. Roughly half
of thecurrent patterns were in his thesis. By OOPSLA '91 it was officiallyan
independent catalog, and Richard had joined Erich to work on it.John started
working on it soon thereafter. By OOPSLA '92, Ralph hadjoined the group. We worked
hard to make the catalog fit forpublication at ECOOP '93, but soon we realized
that a 90-page paperwas not going to be accepted. So we summarized the catalog
andsubmitted the summary, which was accepted. We decided to turn thecatalog into
a book shortly thereafter.
Our names for the patterns have changed a little along the way."Wrapper" became
"Decorator," "Glue" became "Facade,""Solitaire" became "Singleton," and "Walker"
became "Visitor."A couple of patterns got dropped because they didn't seem
importantenough. But otherwise the set of patterns in the catalog has changedlittle
since the end of 1992. The patterns themselves, however, haveevolved tremendously.
In fact, noticing that something is a pattern is the easy part.All four of us
are actively working on building object-orientedsystems, and we've found that
it's easy to spot patterns when youlook at enough systems. But
finding
patterns
is mucheasier than
describing
them.
If you build systems and then reflect on what you build, you will seepatterns
in what you do. But it's hard to describe patterns so thatpeople who don't know
them will understand them and realize why theyare important. Experts immediately
recognized the value of thecatalog in its early stages. But the only ones who
could understandthe patterns were those who had already used them.
Since one of the main purposes of the book was to teachobject-oriented design
to new designers, we knew we had to improve thecatalog. We expanded the average
size of a pattern from less than 2to more than 10 pages by including a detailed
motivating example and samplecode. We also started examining the trade-offs and
the various waysof implementing the pattern. This made the patterns easier to
learn.
Do'stlaringiz bilan baham: |