Chapter 17. The Decorator Pattern

Overview

This chapter concludes the e-commerce case study introduced in Chapter 9, “The Strategy Pattern.”

This chapter

•   Describes a new requirement for the case study: Add header and footer information to the printed sales ticket.

•   Shows how the Decorator pattern handles the requirement flexibly.

•   Discusses how the Decorator pattern can be used to handle input/output (especially Java I/O).

•   Describes the key features of the Decorator pattern.

•   Describes some of my experience using the Decorator pattern in practice.

•   Describes how the essence of the Decorator pattern is not a linked list, but a collection of optional, decorating objects.

A Little More Detail

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