Aspect Orientation

aop
Aspects help in improving the modularisation of a system by encapsulating cross cutting concerns such as distribution, exception handling, debugging, tracing/logging/auditing/timing/testing, design patterns, idioms, etc. The implementation of such concerns usually is spread through the classes and objects of a system. This makes code harder to understand and less maintainable/evolvable.

Aspects can put a) fields and methods to any targetted instance or class and b) code to the beginning and end of any method call. Aspects use designators to attach code. Designators are described using regular expressions. So it is extremely easy, for example to catch all the methods of classes and introduce code that prints the method name as it got called. That makes a simple tracer that can be written in an aspect without touching the application code.

public aspect Trace {
static advice public new(..) & com.ltr.daidalos..* {
before { System.out.println(“Name:”+thisJoinPoint.className);
}
}
}

Aspects can do much more. Current research in aspect orientation suggests that aspects can contain parts of the interraction between classes/instances and meta-level information. A good collection for AOP papers is ECOOP99’s AOP workshop page. More information on AOP you can get from SDA’s publication page.

To use aspect orientation you need AspectJ for Java.
Check AOP’s faq or examine AspectJ’s language specification. Currently the aspectj 0.7beta2 has been released and is available for download.

Leave a Reply

Your email address will not be published.