- Decorating a CoolButton
- Handling Events in a Decorator
- Multiple Decorators
- Nonvisual Decorators
- Decorators, Adapters, and Composites
- Consequences of the Decorator Pattern
- Thought Questions
Decorators, Adapters, and Composites
As noted in Design Patterns, there is an essential similarity among these classes that you may have recognized. Adapters also seem to “decorate” an existing class. However, their function is to change the interface of one or more classes to one that is more convenient for a particular program. Decorators add methods to particular instances of classes rather than to all of them. You could also imagine that a composite consisting of a single item is essentially a Decorator. Once again, however, the intent is different.