Chapter 27. Decorator
To extend a codebase, you ordinarily add new classes or methods to it. Sometimes, though, you want to compose an object with new behavior at runtime. The INTERPRETER pattern, for example, lets you compose an executable object whose behavior changes radically depending on how you compose it. In some cases, you may need small variations in behavior and want to be able to mix them together. The DECORATOR pattern addresses this need. DECORATOR lets you compose new variations of an operation at runtime.
A Classic Example—Streams
The .NET FCL provide a classic example of the DECORATOR pattern in the overall design of input and output streams. A stream is a serial collection of bytes or characters, such as those that appear in a document. ...