The decorator pattern are often wont to extend (decorate) the practicality of a particular object statically, or in some cases at run-time, severally of different instances of an equivalent category, provided some groundwork is finished at style time. this can be achieved by planning a brand new decorator category that wraps the first category. This wrapping can be achieved by the subsequent sequence of steps:
Subclass the first “Component” category into a “Decorator” category (see UML diagram);
In the Decorator category, add a element pointer as a field;
Pass a element to the Decorator builder to initialize the element pointer;
In the Decorator category, direct all “Component” ways to the “Component” pointer; and
In the ConcreteDecorator category, override any element method(s) whose behavior has to be changed.