Skip to main content

Decorator

The Decorator design pattern attaches additional responsibilities to an object dynamically. This pattern provide a flexible alternative to subclassing for extending functionality.

Usage     Usage     Medium

UML class diagram​

A visualization of the classes and objects participating in this pattern.

diagram

Sample code​

This structural code demonstrates the Decorator pattern which dynamically adds extra functionality to an existing object.

Output​

See also​

​