A Primer for Aspect-Oriented Programming in Java

Tim Stevens has written A Primer for Aspect-Oriented Programming in Java which quite neatly sums up how OO and AOP sit together.

What is good about this article is that it discusses pragmatic usage rather than just what you could feasibly do with AOP. For the management there is a good beginning and end, for the Java developer there is a concrete example to get their teeth into.

My personal opinion of the usage of AOP alongside traditional OO is that you can use AOP to de-clutter your OO. This means that your OO can remain more closely related to what it does best, the business data and logic; which leaves the execution environment concerns and externalisation to AOP aspects.

As the article points out the AOP compiler/classloader has the ability to completely change the way the compiled code functions. This scares a large number of people who have an interest in quality, because they cannot determine how the program will function. However OO runtime dispatching has the same facility within a smaller scope, and I think it will just be a matter of time and experience before AOP is accepted in the same way.

One last point worth mentioning for those just starting to look at AOP, and that is the concept of dimensions. AOP currently comes in 2 flavours, single dimension and multi-dimensional. You can think of multi-dimensional as having aspects of aspects in addition to aspects of core code. It is for this reason that Hyper/J is worth looking at. Using a multi-dimensional AOP engine is a harder mental leap, but one worth making if you are going to use AOP to its maximum potential.

No comments: