Jump to: navigation, search


408 bytes removed, 17:04, 26 February 2007
Decorator, a [ structual pattern] also known as wrapper(acts as an interface between its caller and the wrapped code), adds additional functionality to a class at runtime through composition. Decorators are alternative to subclassing which add behaviour at compile time. By wrapping, it allows us to add things to the component without requireing every subclass to inherit these new qualities. Each decorator class wraps a component, which means the decorator has an instance variable that holds a reference to a component.  where subclassing would result in an exponential rise of new classes. * allows us to add things to a component without requiring every subclass to inherit these new qualities.* Function added at runtime through composition.* We want an object to do something new, not its class* "Classes should be open for extension, but closed for modification

Navigation menu