Chapter 17. Implementing Creational Object-Oriented Design Patterns

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

Get AspectJ Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.