Decorator pattern versus sub classing

from Decorator pattern at wikipedia

The decorator pattern can be used to
make it possible to extend (decorate)
the functionality of a certain object
at runtime.

The whole point of decorator pattern is to dynamically add additional behaviour/functionality, which is of course not possible at design time.

from the same article:

The decorator pattern is an
alternative to subclassing.
Subclassing adds behavior at compile
time
, and the change affects all
instances of the original class;
decorating can provide new behavior at
runtime for individual objects
.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)