Design Pattern Implementations using Aspect-Oriented Programming

 

 

Software design patterns offer flexible solutions to common software development problems. Each pattern is comprised of a number of parts, including purpose/intent, applicability, structure, and sample implementations. A number of patterns involve crosscutting structures in the relationship between roles in the pattern and classes in each instance of the pattern.

 

When the software design patterns were first identified, the sample implementations were geared to the current state of the art in object-oriented languages. Since then, aspect-oriented programming has been proposed as a means of modularizing crosscutting concerns in software. Other work has shown that the implementation language affects pattern implementation, which makes it only natural to explore the effect of aspect-oriented programming techniques on the implementation of the well-established design patterns.

 

GoF Design Patterns in Java and AspectJ

 

Joint with Gregor Kiczales

 

As an initial experiment we chose to develop and compare Java and AspectJ implementations of the 23 GoF (Gang-Of-Four, stands for the authors of Design Patterns: Elements of Reusable Object-Oriented Software. Gamma et. al. Addison-Wesley, 1995). AspectJ is a seamless aspect-oriented extension to Java, which means that programming in AspectJ is effectively programming in Java plus aspects. By focusing on the GoF patterns, we are keeping the purpose, intent, and applicability of 23 well-known patterns, and only allowing the solution structure and solution implementation to change. So we are not discovering new patterns, but simply working out how implementations of the GoF patterns can be handled using a new implementation tool.

 

For the 23 patterns, we managed to remove the code-level dependencies from the participants in 17 cases. For 12 of these, we developed reusable implementations that can be integrated into software systems as "library pattern aspects". The examples illustrate differences in Java and AspectJ implementations

 

Our results indicate that using AspectJ improves the implementation of many GoF patterns. In some cases this is reflected in a new solution structure with fewer or different participants; in other cases, the only the implementation of the classes in the originally proposed solution changes (for example by moving pattern code from the participants into an aspect).

 

Downloads

 

The following downloads are available. You will need to have Java (version 1.2 or higher) and AspectJ (version 1.1 or higher) installed to run the examples. Please refer to the readme files for details on running the examples.

 

Current Version 1.11

 

  • A collection of Java and AspectJ implementations of the 23 GoF patterns, version 1.11 - Each design pattern is represented by a sample system implemented in both Java and AspectJ. This includes the library of 12 reusable pattern aspects. The example code is intentionally kept simple. Note that while all classes are extensively commented using ajdoc, ajdoc may not work with latest AspectJ versions.
    • Code base from April 01, 2004 [, 355K] - please refer to the readme files in the /docs directory for details on setting up your system, and compiling and running the examples.
    • Release notes [, 3K]
     

Older versions (not available anymore)

 

  • Old pattern implementations, version 1.1 - basically the same as version 1.11 above, except for the Observer, FactoryMethod and Facade implementations. Code base from February 25, 2004
  • Old pattern implementations, version 1.0 - based on an older version of AspectJ (1.0.6). We recommend you use the latest version instead (see above). Code base from November 25, 2002

 

Known Issues

 

  • The code base has not yet been updated for Java 5.

 

Publications

 

  • Jan Hannemann and Gregor Kiczales. Design pattern implementation in Java and AspectJ. In Proceedings of the 17th Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA ’02), pages 161–173. ACM Press, 2002.  [Link]

 

 

 

 


 

Contact

 

We are very interested to hear your feedback on this work. Please send all questions, comments and suggestions to the address given in the contact section of the main page.

 Las

Last Modified: 2007/10/16;


Page Information

  • 3 months ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information

Recent PBwiki Blog Posts