The Decorator Pattern allows additional responsibilities to be attached to an object dynamically at runtime. Decorators provide a flexible alternative to subclassing for extending functionality.
The Decorator Pattern was applied to a coffee ordering example to dynamically add condiments like milk, soy, mocha, etc. to coffee types. Beverage is an abstract base class that concrete coffee types like HouseBlend and DarkRoast extend. Condiments are implemented as Decorator classes that extend an abstract CondimentDecorator class, allowing them to wrap and extend a Beverage object. This allows any number of condiments to be added at runtime without subclass explosion.