February 2000
Intermediate to advanced
352 pages
6h 31m
English
The Decorator pattern provides us with a way to modify the behavior of individual objects without having to create a new derived class. Suppose we have a program that uses eight objects, but three of them need an additional feature. You could create a derived class for each of these objects, and in many cases this would be a perfectly acceptable solution. However, if each of these three objects requires different features, you would have to create three derived classes. Further, if one of the classes has features of both of the other classes, you begin to create complexity that is both confusing and unnecessary.
For example, suppose we wanted to draw a special border around some of the buttons in a toolbar. If ...
Read now
Unlock full access