From the course: C++ Design Patterns: Structural

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Overview

Overview

- [Instructor] The decorator is a structural design pattern that allows adding new behavior to an object dynamically without entering its structure. The pattern involves wrapping an object inside a decorator object, which adds the required behavior. This design pattern is best suited for projects where we want to extend the functionality of an object without sub classing. The UML diagram of the decorator looks similar to the composite design pattern. We have a common base class or interface called component. This interface is implemented by concrete component classes. We also have a decorator class which implements the component interface and maintains a single reference to the component object. That's the difference between the composite design pattern and the decorator design pattern. Instead of having a collection of components, the decorator only has a single reference to the component. That's because the decorator's purpose…

Contents