Chapter 27. Decorator

Ordinarily, an object inherits behaviors from its superclasses. As earlier chapters have shown, you can apply the STATE and the STRATEGY patterns to alter the behavior of an object dynamically. Like STATE and STRATEGY, the DECORATOR pattern relies on polymorphism, but DECORATOR combines polymorphism with delegation to let you extend an object's behavior. The intent of DECORATOR is to let you compose an object's behavior dynamically.

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.