Now, we will now get to know the Decorator Design Pattern.
The intent of the Decorator Design Pattern is to attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub-classing for extending functionality. The pattern is used to extend the functionality of an object dynamically without having to change the original class source or using inheritance. This is accomplished by creating an object wrapper referred to as a Decorator around the actual object.
Via a real life example, you will learn how and when the Decorator design pattern should be used and how to structure your code in order to implement it. You will see how it can lead to elegant solutions to code problems.