In this chapter, we presented the aspect-oriented implementation of five well-known design patterns: Singleton, Observer, Command, Chain of Responsibility, and Proxy.
For these five cases, the implementation follows this principle: an abstract aspect is defined to hold the code that is generic in the implementation of the pattern. This abstract aspect defines abstract pointcuts that designate the locations in the program where the pattern is to be integrated and the conditions under which the pattern must be triggered. This abstract aspect is then extended to define the code, which is specific to, for example, a command or a proxy.
The aspect-oriented implementations of these five design patterns lead to solutions that are more interesting than pure object-oriented, aspect-free implementations. It is, however, not the case for all existing design patterns. Patterns such as the Factory pattern or the Inter- preter pattern do not benefit as much from aspects.
• The pattern defines a crosscutting structure.
• The four criteria of locality, reusability, composition transparency, and (un)pluggability defined by Hannemann and Kiczales are met.
• The pattern leaves the structure of the base program unchanged.
Unable to display preview. Download preview PDF.