Design Patterns and AOP

  • show all 0 hide

Purchase on Springer.com

$29.95 / €24.95 / £19.95*

* Final gross prices may vary according to local VAT.

Get Access

Summary

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.

Deciding whether a design pattern will benefit from an aspect-oriented implementation is a matter of evaluating whether

  • • 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.