Using the decorator design pattern for a hierarchy of classes
问题 Looking at the following (simplified) hierarchy of classes: > Email (base class) > SimpleEmail extends Email > HtmlEmail extends Email I need to decorate Email.send() to add throttling functionality. I need to instantiate SimpleEmail, HtmlEmail or other similar subclasses of Email. What should this pattern look like exactly? My guess (which surly needs correcting) is as follows: class abstract EmailDecorator -> Define a constructor: EmailDecorator(Email component) -> Implements all methods of