Jump to content

Decorator pattern

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TakuyaMurata (talk | contribs) at 20:40, 3 January 2003. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Intent: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

While reading the GangOfFour book on CD I noticed that the original name of this pattern was "Wrapper". -- DaveMitchell

See also: CompositePattern, ProxyPattern, DesignPatterns

This pattern was also called shadowing in LPC.


http://home.earthlink.net/~huston2/dp/decorator.html

http://wiki.cs.uiuc.edu/PatternStories/DecoratorPattern

http://patternsinperl.com/designpatterns/decorator/ - Perl implementation


This pattern can also be used as a way to refactor a complex class into smaller pieces. Even if you don't need to attach responsibilities dynamically it can be clearer to have each responsibility in a different class. -- ChristianTaubman


CategoryPattern | CategoryStructuralPatterns