Demeter Logo

Aspect-Oriented Concepts in Demeter

We show several instantiations of the basic aspect-oriented idea in Demeter. The purpose is to show (1) that the basic aspect-oriented idea is versatile and can be used simultaneously in the same tool (2) that aspect-oriented concepts have been used in Demeter starting in the late eighties.
AO Pattern:
ALL, POINTCUTS, ADVICE

The AO pattern is about crosscutting enhancements. ALL is a set
of elements to be enhanced. Each of those elements defines
a set of joinpoints where enhancements may be added. 
POINTCUTS is a language
for specifying sets of join points for elements in ALL.
ADVICE is a language for specifying enhancements for pointcuts (sets
of join points) for elements in ALL.


Instance 1: Demeter/C++, DemeterJ, DJ: dynamic:
First publication: 1992
Short Description: Traversal enhancement 

ALL:       Traversal programs for the object graphs of some class graph.
	   Enhancements may be added when traversal reaches a
	   node or edge in object graph. Enhancements are methods
	   to be executed when traversal reaches certain nodes/edges.
POINTCUTS: visitor method signatures
ADVICE:    visitor method bodies (before, after, around)

The visitor method signatures can be simulated with the following
AspectJ pointcuts: call, target, this (or call, target, args,
depending how the traversal code is generated). The transportation
patterns of Demeter/C++ can be simulated with the cflow pointcut
of AspectJ. The context visitor of DJ can be simulated by cflow as well.
The pointcut  language is limited in that it does not support set 
theoretic operations.

This instance assumes that a traversal program is given
by some means and it is not important that it be specified by
a traversal specification. The most effective use of instance 1
happens when it is combined with instance 2.

In this instance we use aspect-oriented programming
only in a special way: we focus on a subcomputation (the traversals)
of the base program and not like AspectJ, the entire dynamic call graph.


Instance 2: Demeter/C++, DemeterJ, DAJ: static:
Short Description: Traversal interpretations 
First publication: 1992

ALL:       Class graphs. Enhancements may be added to the classes 
           of those class graphs. Enhancements are additional methods
	   that are added to the classes.
POINTCUTS: traversal spec. s, class graph g
ADVICE:    s, g

The traversal specification s defines a set of methods to be added
to the classes. The traversal specification language has similarities
to AspectJ pointcuts; however, it is used to define introductions.
Demeter supports
computed introductions, while in AspectJ introductions are hard-coded.

Traversal specifications support union, intersection and negation
(bypassing) for computing introductions.



Instance 2.1: DJ
Short Description: Traversal interpretation variations

ALL:       Class graphs. Enhancements are additional methods for class
	   graphs, indirectly adding methods to some of the classes.
POINTCUTS: traversal spec. s, class graph g
ADVICE:    s, g
           method name (fetch, gather, asList, traverse)

A traversal specification has different interpretations based 
on an additional method name.


Instance 2.2: DJ, object graph semantics
Short Description: First sets for object graph

ALL:       Object graphs of some class graph. Nodes in object graphs 
           may be enhanced with a selection of edges outgoing
	   from node.
POINTCUTS: traversal spec. s, class graph g 
ADVICE:    s, g
           edges to traverse at object graph nodes 

At a node n of some object graph we select an edge e iff
there exists an object graph at the target of e that satisfies
the rest of the traversal specification s.


Instance 3: Demeter/C++, DemeterJ: static: 
Short Description: Open classes

ALL:       classes 
POINTCUTS: pattern defining set of classes
ADVICE:    add members


Instance 4: Demeter/C++, DemeterJ: static: 
First publication: 1988
Short Description: concrete syntax is more abstract than abstract syntax

ALL:       Classes defined by some class graph
POINTCUTS: Trivial: all classes of class graph
ADVICE:    class graph with tokens (class dictionary)

A class graph with tokens (called a class dictionary in Demeter)
defines a domain specific language for objects along with a
parser and printer. The parser and printer cut across all
classes defined by the class dictionary. DemeterJ defines
a printing visitor; Demeter/C++ a printing method. 
DemeterJ defines a parsing method for each class.


The four instances of the AO pattern presented above are the 
most important ones. There are two more instances developed
by Crista Lopes which were the starting point of AspectJ.

Instance 5: DemeterJ: COOL: aspect-specific language
First publication: 1994
Short Description: synchronization aspect

ALL:       Method calls in Java programs.
POINTCUTS: Exclusion sets describing which methods may not be called
	   simultaneously.
ADVICE:    Method managers


Instance 6: DemeterJ: RIDL: aspect-specific language
First publication: 1995
Short Description: data transfer aspect

Similar to instance 1. Traversal specifications are used
to define a marshalling program.

For details about instances 5 and 6 see Crista Lopes' PhD thesis.