Applying the Decorator Pattern to the Case Study

In the case study, the SalesTicket is the ConcreteComponent. The concrete decorators are the headers and footers. Figure 15-5 shows the application of the Decorator pattern to the case study.

Figure 15-5. Setting up headers and footers to look like a report.

Figure 15-6 shows the application of Decorator to one header and one footer.

Figure 15-6. An example Decorator object diagram.

Each Decorator object wraps its new function around its trailing object. Each Decorator performs its added function either ...

Get Design Patterns Explained: A New Perspective on Object-Oriented Design 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.