Friday, 23 March 2007

Decorator Pattern


Decorator Pattern is used when components (instances of Component) are to be extended dynamically by functionality. Without changing the structure of a class, one class adds more functionality to other class.
Decorator eleminates the need for subclassing and add the additional behavior/funcionality at runtime.
I think decorator pattern can also be very helpful for coders when end user requests more additional features when task is almost complete. Because without changing the structure of one class coder can create another class with less effort and with less chances of logical errors, that will add all extra required features.

1 comment:

Iqbal said...

Hi rizwan,
you have given a good but brief description of the decorator pattern. It does add flexibility to the design. However, it is worth mentioning that it can sometimes also add a lot of small classes to a design which can result in a design that is less straightforwad for others to understand