Decorator pattern
There are times when we need to add or remove functionality to/from existing code, without affecting it, and when it is not practical to make a subclass. The decorator comes in handy in these cases because it allows doing so without changing the existing code. It does this by implementing the same interface, aggregating the object that it is going to decorate, delegating all the common interface calls to it, and implementing in the child classes the new functionality. Apply this pattern to classes with a lightweight interface. In other cases, it is a better choice to extend the functionality by injecting the desired strategies into the component (strategy pattern). This will keep the changes local to a specific method, without the need to re-implement the other ones.
The decorated object and its decorator should be interchangeable. The decorator's interface must fully conform to the decorated object's interface.
Since it uses recursion, new functionality can be achieved by...