I've always liked to point out that the Input
Stream hierarchy in Java (yes, it's JDK 1.0, but it's still there...) is an example of the
DecoratorPattern. Specifically, all Input
Streams are either leaves (e.g. File
Input
Stream, String
Buffer
Input
Stream) or Decorators (e.g. Filter
Input
Stream and its subclasses). In fact, this hierarchy nicely shows all three ways in which Decorators can extend their "Wrapped" objects, e.g by additional state (Line
Number
Input
Stream), additional methods (Pushback
Input
Stream) or extended core methods (Buffered
Input
Stream).
KyleBrown