Decorator

E173611

The Decorator is a structural design pattern that allows behavior to be dynamically added to individual objects by wrapping them in flexible, reusable decorator classes.

All labels observed (4)

Label Occurrences
Decorator pattern 3
ConcreteDecorator 1
Decorator canonical 1

How this entity was disambiguated

Statements (49)

Predicate Object
instanceOf software design pattern
structural design pattern
alsoKnownAs Decorator
surface form: Wrapper pattern
applicableWhen extending behavior of individual objects, not entire classes
object responsibilities should be added or removed dynamically
subclassing is impractical or leads to many subclasses
authors Erich Gamma
John Vlissides
Ralph Johnson NERFINISHED
Richard Helm
avoids class explosion from excessive subclassing
belongsTo Design Patterns: Elements of Reusable Object-Oriented Software
surface form: Gang of Four design patterns
category object structural pattern
commonLanguageSupport C# programming language
surface form: C#

C++
Java
JavaScript
Python
consequence can make debugging and configuration more complex
increases number of small objects in a system
preserves original object interface
definesRelationship ConcreteDecorator adds responsibilities to Component
Decorator implements same interface as Component
Decorator maintains reference to a Component
describedIn Design Patterns: Elements of Reusable Object-Oriented Software
differsFrom Adapter changes interface, Decorator preserves interface
Proxy controls access, Decorator adds responsibilities
exampleUseCase adding encryption or compression to I/O streams
adding responsibilities to logging components
adding scrollbars to a window in GUI frameworks
adding validation or caching to service calls
intent Attach additional responsibilities to an object dynamically
Provide a flexible alternative to subclassing for extending functionality
keyProperty decorators are transparent to clients
decorators can be combined in different orders
multiple decorators can be stacked
originYear 1994
relatedTo Adapter
surface form: Adapter pattern

Composite
surface form: Composite pattern

Proxy pattern
structureElement Component interface
Composite
surface form: ConcreteComponent

Decorator self-linksurface differs
surface form: ConcreteDecorator

Decorator abstract class
supports open-closed principle
runtime behavior extension
single responsibility principle
typicalOperation add pre-processing or post-processing around forwarded calls
forward requests to wrapped component

How these facts were elicited

Referenced by (6)

Full triples — surface form annotated when it differs from this entity's canonical label.

Adapter relatedTo Decorator
this entity surface form: Decorator pattern
Decorator alsoKnownAs Decorator
this entity surface form: Wrapper pattern
Decorator structureElement Decorator self-linksurface differs
this entity surface form: ConcreteDecorator
Chain of Responsibility relatedTo Decorator
this entity surface form: Decorator pattern
Strategy relatedTo Decorator
this entity surface form: Decorator pattern