[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] GoF design patterns and AspectJ, updated
|
Just a plug: If you haven't checked out these patterns already, I
highly recommend it. They are excellent examples of how to use AspectJ
and taught me a lot about AOP design.
Cheers,
Nick
On Mar 11, 2004, at 9:43 PM, Jan Hannemann wrote:
Hi all,
As part of our ongoing work on design patterns and AOP, we have
recently
updated our library of AOP implementations of GOF design pattern. The
new
code can be downloaded from http://www.cs.ubc.ca/~jan/AODPs/
The new implementations are more concise, and show how the AspectJ
implementations of the patterns make the two different perspectives on
the
system (the concrete participants and abstract design pattern) more
apparent. We did this by avoiding type names in our participant
classes that
correspond to roles in the pattern. Thus, it is easier to distinguish
between the abstract pattern roles (like Observer, Composite,
ConcreteCommand) and the concrete types in the examples (like Screen,
Directory, or ButtonCommand). We believe this clarifies the examples
considerably. Note that some AspectJ library implementations use empty
interfaces internally to describe roles. Here we use pattern role
names,
since they are not bound to a particular example, but to a general
pattern
implementation. Being able to see clearly in the code that: "[...]
Point
implements Subject" and "[...] Screen implements Observer" helps to
cleanly
conceptualize how pattern and participants map to each other.
For those who do not know about this project: we implemented sample
systems
using the 23 GoF design patterns in AspectJ (and Java, for
comparison). For
most of the 23 patterns we achieved a better decoupling between the
participants using AspectJ. Unsurprisingly, the patterns involving
crosscutting profit the most from an AOP implementation. For 12 cases,
the
patterns could be given a reusable AspectJ implementation, which means
that
we created a small library of reusable design pattern aspects. The
other
examples show differences in Java and (non-reusable) AspectJ
implementations. Most design patterns show some form of modularity
improvement in their AspectJ version (compared to the Java version).
All
examples are documented in ajdoc.
The reusable library aspects are abstract aspects that define the
workings
of the pattern: roles, communication protocols, and ordering of
events. For
instances of design patterns, these abstract aspects are extended by a
concrete aspect that assigns the pattern roles to participant classes,
identifies conceptual operations by concretizing abstract pointcuts,
and
concretizes abstract methods. Both the reusable and the non-reusable
implementations usually increase modularity of the (example) systems by
moving dependencies between the pattern participants to aspects.
Of course, we are always interested in improving the code base. Please
feel
free to contact me for comments, questions, or suggestions. We are
also very
interested in concrete applications of AOP design patterns - please
share
your experiences with us.
Jan Hannemann
Department of Computer Science
University of British Columbia
Canada
jan@xxxxxxxxx
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users