November 2019
Beginner to intermediate
674 pages
15h
English
To better illustrate the power and problems of writing decorators, the StreamDecorator project from the folder folder implements a decorator for the TStream class. The DecoratedStream unit implements a decorator that extends the TStream class (and its subclasses) with eight new functions.
The problem with decorating rich classes such as TStream arises from the fact that the decorator must implement complete TStream interface. In the case of TStream, that means writing lots and lots of functions. Just the declaration of the decorator is a whopping one hundred and eighty-five lines long! The following code fragment shows just a few parts of that declaration:
type TDecoratedStream = class(TStream) strict private FWrapped: ...
Read now
Unlock full access