In this video, we are going to talk about the decorated pattern, which has the scope to add new functionality
to an object without affecting its structure.
This pattern creates a decorator class, which wraps the original class and provides additional functional
beekeeping class method signature untouched.
The decorator adheres to the single responsibility principle, which states that each object should
have the responsibility of a single part of the functionality of a software.
In other words, a class should do only one thing and two well.
To achieve this decorator's use of principles like inheritance and composition.
Let's a look at the following diagram.
The component class is usually the abstraction, which can be either an interface or an abstract class.
This class is implemented by the concrete component.
As you may have guessed, the concrete component will be decorated.
The decorating class will be inheriting the same component interface in order to make it similar to
the concrete object that is being decorated.
Below, we can have multiple complete decorator's for the same object.
One of the weaknesses of this pattern can be the fact that a new class will be required by each new
feature, which will increase the volume of the code.
Let's have a look on how all this looks in code.