I know atrox just posted the article on AOP the other day --and it is a good intro -- but I have been working through AspectJ in Action: Practical Aspect-Oriented Programming
by Ramnivas Laddad the last few weeks.
Too much "don't worry about that, we will explain it later." Otherwise, it is a solid book with many good examples. Even better, some of the examples are code you might actually want to use.
4.5 out of 5.2 penguin heads.
Now that that is out of the way, AOP is friggin cool. The whole idea is basically you can match types of operations such as member assignments, method calls, etc, and creat "Aspects". These are specialized classes where you can say "Do this before you call a method that looks like "calculate*(..)". While AOP isn't as fundamental a shift as OOP was to some, its pretty powerful.
There are some caveats though. I can see code getting very confusing if you have many Aspects layered on a system over time. I still like Dynamic Proxy patterns myself, but this is a more efficient way to do things. It places a lot of emphasis on getting your naming conventions in order. Im also not sure I buy some of the things they suggest -- like transaction management -- as being better with Aspects. However, this is seriously a tool you should have in your bag.
Comments
Re: Review: Aspect J in Action
I first saw this a year or so ago and it intrigued me as well. For some really basic things like logging and tx control it seemed really clean, much more so than any system that I've tried before. I'll have to wait a bit before trying it out, but I think that it'll take off pretty well. I agree, it'll probably just get assimilated into languages as opposed to some huge paradigm shift.
Re: Review: Aspect J in Action
i guess i dont understand it totally because it didnt seem "better" to me. it sort of seemed a bit whack, albeit useful.
what i mean is if i understand it it has its own compiler that basically weaves your aspect code in as it goes. yes it uses the sig to tell where to put its before and after and during stuff but the resulting bytecode is the original class weaved with aspect stuff.
that seems clunky to me? i mean i now have a special compiler that has to throw stuff into my code? seems like it could get very hairy to maintain.
i am surely wrong and dont understand it though, enlightenment to follow?
Re: Review: Aspect J in Action
Well, I don't think its "clunky", but yeah, my read on it is if you go overboard, it could get very hairy to maintain. It does give you some notable benefits:
1. The ability to "patch" operational changes to binary classes.
2. The ability to keep the duct-tape/join poin code in one place.
3. A vast reduction in copy-paste and housekeeping code.
Yeah, you need the compiler, but I don't know that using ajc rather than javac is that big of a deal.