Build Stream Wrappers

Decorator pattern

Challenge 3 of Wrap & ExtendIntermediate~55 minFree

Build the machinery behind I/O stream wrappers like gzip, base64 and text codecs from the Decorator pattern up. You will define a source with a read() method, a Decorator base that wraps another stream and keeps the exact same interface, then stack transformers (uppercase, reverse, repeat, call counting) that add behavior without either the source or the caller knowing the difference.

5 steps

  1. 1Source and Decorator base
  2. 2UpperCase transformer
  3. 3Reverse and stacking
  4. 4Repeat with parameters
  5. 5Counting transparently
Start step 1