Archive for August, 2006

Aspect Oriented Programming in a commercial app

I have read about the benefits of aspect orientated programming (AOP) and decided to investigate the possibility of using an open source AOP Framework to standardise exception handling in our application.

Click here for a list of Open Source Aspect Orientated Frameworks

From what I had read I had great hopes for AOP: I was expecting to be able to add exception handling and logging to some classes by writing an exception handling class using the AOP framework and then using a configuration file, configure which classes magically had exception handling applied.

Unfortunately there is no such thing as magic (sorry kids), there needs to be a way of weaving the code written for exception handling (Advice) into the methods specified by the configuration file.

The AOP frameworks seem to take two different approaches to weaving, Compile time weaving and Run time weaving; each of these solutions have their own compromises.

I initially discounted using a Compile time weaving framework such as AspectDNG, because of the impact on our build process.

I first looked into Runtime weaving implementation AspectSharp but after discovering a bug running their example I found a message on the forum saying the AspectSharp project had stalled. I next looked at the SpringFramework which at first seemed promising, I was disappointed to find out that in order to use runtime weaving you are faced with a few rather large compromises: Firstly the classes in which you want to apply the Advice to have to implement an interface, which isn’t so bad I suppose. Secondly however there is a bigger compromise, every call you make to your classes must be replaced with a call to a proxy.

so

command.Execute();

would be replaced with,

ICommand command = (ICommand) ctx[”myServiceObject”];
command.Execute();

Is this intrusive use of a proxy just a bit too much of a compromise to have your domain logic free from distractions like tracing and exception handling? I suppose the answer is “it depends”. For my situation this was too much of a risk, I didn’t have time to investigate any performance penalties, but this surely must be an issue too.

The future of AOP must be with compile time weaving; if this could be integrated smoothly with Visual Studio and the build process then this surely would be an attractive option.

Comments del.icio.us