The Decorator Design Pattern adds responsibilities to an object at run time by wrapping it with objects that share its interface. It provides a flexible alternative to hardcoding every variation into the original class. section 14.0 section 14.3
A ticket class that stores party access, VIP seating, and drink coupons as attributes must know every enhancement and calculate each one explicitly. Adding, removing, or changing an enhancement therefore requires modifying Ticket and can create change leaks. section 14.3.2
The refactored design makes BaseTicket and every enhancement a Ticket. Enhancement stores another Ticket, and its cost is its own price plus the wrapped ticket’s cost. Party, VIP, and Coupon can therefore be chained in any order while client code treats the result as a ticket. section 14.3.3
Building an enhanced ticket
Start with BaseTicket(), then wrap it successively: Party(ticket), VIP(ticket), Coupon(ticket), and Coupon(ticket). Calling cost on the outermost object traverses the chain and produces the combined total. A different chain can add three coupons and party access without changing Ticket or the decorators.
Figure 14.12 The generic model of the Decorator Design Pattern. Compare with figure 14.11. A ConcreteComponent object by itself is a Component. A ConcreteComponent wrapped by Decorator objects is also a Component. The private component instance variable of superclass Decorator is either a ConcreteComponent object or a Decorator object. This chain implements the nested wrapping of the Decorator objects.
Use the generic model to map Component, ConcreteComponent, Decorator, and ConcreteDecorator roles onto a wrapping architecture. section 14.3.4

