Decorator

The decorator pattern is an incredibly useful tool that helps you enhance existing interfaces with an additional functionality and without changing the original implementation. In addition to that, we can apply this additional functionality to any subclass of the original implementation. As such, the decorator is a useful tool for enhancing existing behavior.

A Christmas tree by itself doesn't do much. It stands in one place and looks nice. We can, however, enhance its value by adding decorations, such as colorful lights. This decoration doesn't change the original interface of the tree—it just improves it. Furthermore, we can apply the same decoration to many different kinds of trees, not just a specific sort.

Every decorator operates ...

Get Hands-On Design Patterns with Delphi 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.