[]
AOP is not just de-scatter, de-tangle
[ tirsen ] 11:16, Tuesday, 1 June 2004

I've used AOP more or less actively for almost two years now, and I think I'm really starting to get it. Given that it took me almost 5 years to really master object-orientation I would say AOP is quite a lot easier. (Granted, I learned OOP through C++ which made it a lot harder).

Anyway, there's an important design characteristic of AOP that I've been starting to appreciate more lately. Most people talk about AOP as it's all about moving things that has been implemented in several places into one place, and separating things that has been cramped up into one single place into several places. I think there's a different important part to it though. I call it Dependency Inversion on Stereoids.

The Dependency Inversion Principle is basically the old OO principle for managing type dependencies in an object-oriented system. Given you have a dependency:
A -> B
If you want to minimize dependencies and separate A and B, you would introduce an interface or baseclass that B implements and A depends on ("implementation" is a type dependency where the implementation depends on the interface). So you would get:
A -> I <- B
Voila! You have inverted the dependencies and separated A from B!

But with AOP you have a much more direct and powerful dependency inversion (it's on stereoids!). So from:
A -> B
If you make B an aspect you can completely and directly invert the dependency:
A <- B
B would depend on A in this case, but you could completely eliminate the extra luggage in A that makes it call into the interface I in the right places.

This is a new powerful design construct, you wouldn't use it all the time but it allows you a new degree of freedom. For example, you could let one team develop a domain model and another team bolt on undo or persistence on it (I know Crazy Bob is doing this).


Comments

Good observation!

Here's a piece I wrote early that talked about the dependency aspect above.

http://www.manageability.org/blog/archive/20030519%23refactoring_to_aspects/view

The important point like you said is that the dependency is inverted!

--Carlos E. Perez, June 1, 2004 12:53 PM

I agreed,
But it's not only about it. The nice term to mention is oblivious, how oblivious A from B and in most cases it isn't totally independent.

--Renat Zubairov, June 1, 2004 05:54 PM
Post a comment









Remember personal info?