Introduction


With the release of the seminal book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Addison-Wesley), the now infamous Gang of Four (GoF) design patterns became formally recognized as a useful practice in object-oriented (OO) software development.

The GoF book was split into three categories of design pattern: Creational, Structural, and Behavioral. The original GoF design patterns were designed to be implemented using the mechanisms available in most OO languages. Aspect orientation, when implemented using AspectJ, adds new mechanisms with which these patterns can be applied:

  • The code that deals with the mechanics of a design pattern can be modularized out of the rest of the business logic so as to be less intrusive.

  • In Java, inheritance relationships between classes must be used with care since Java allows only one inheritance relationship between two classes. Aspects can provide mechanisms by which the more generic pattern-oriented relationships can be applied seperately from any core business relationships between classes. Therefore, aspects can remove the need for an abstract base class leaving the classes with as much freedom as possible to define the right relationships for their business logic without the design pattern getting in the way.

  • A by-product of the above two advantages is that code is clearer and easier to understand because of the removal of pattern-focused relationships and logic from the business logic classes thanks to the modularization of the patterns into aspects.

All three categories of design pattern from the GoF book can benefit from an aspect-oriented implementation and this chapter focuses on the Creational patterns.

The pattern implementations described in the next three chapters are based on Jan Hannemann and Gregor Kiczales's work for the 17th Annual ACM conference on Object-Oriented ProProgramming, Systems, Languages, and Applications (OOPSLE). Go to http://www.cs.ubc.ca/~jan/AODPs/ to check out the original research.




AspectJ Cookbook
Aspectj Cookbook
ISBN: 0596006543
EAN: 2147483647
Year: 2006
Pages: 203
Authors: Russ Miles

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net