Another approach to implementing cross-cutting concerns is to use the decorator pattern. The decorator pattern can add behaviors dynamically to an object, including behaviors for cross-cutting concerns. It is essentially like creating a wrapper to handle a cross-cutting concern around some other object. The following diagram shows the decorator pattern:
In the preceding diagram, the ConcreteComponent class implements the IComponent interface and is a class that can either be used on its own or wrapped in one or more decorators. The Decorator class is an abstract class that also implements the IComponent interface ...