Decorator Pattern

A decorator class allows you to add more capacity to an existing class while leaving the original class untouched. It has certain advantages over inheritance.

It can be used when you needed to construct a “bridging” class that was capable of extending the operability and functionality of a base class, but without having to introduce changes in its original structure

Indeed, one of the most appealing aspects of the decorator design pattern is the ease with which you can use a class of different type to extend the capabilities of another. Of course, this isn’t always the best course of action to take, simply because it can be much easier to modify the original class by using inheritance, but there are situations where a decorator class can find its place inside an application.