The decorator design pattern is a structural, hierarchical pattern that is used to dynamically extend or alter the functionality of objects at runtime. This pattern builds the functionality at each level without altering the existing structure using the composition from similar data types. It does this by wrapping them in an object of a decorator class, providing the additional functionality and leaving the original object intact without any modification.
Using this pattern, we can add functionality by wrapping an object inside another without affecting the other parts of the hierarchy in the system. This is also known as a wrapper as it wraps the objects. This differs from adding functionalities to objects at design-time, which generally involves inheritance. To add any functionality, we have to create a new class and create a subclass that...