On Thu, 2004-02-12 at 10:39, Sonnek, Ryan wrote:
> Thanks Vincent.
> I'm really new to AOP and wanted to really see what all the hype was about.
> I'm looking at taking my existing project and seeing if I can inject some
> AOP goodness and see what the outcome is.  It's really just to get a feel
> for AOP and I think that aspectwekz is the way to go since at it's core,
> it's still java.  No offense to aspectj, but I don't feel comfortable
> learning a new language (the new semantics), to try out a new 'java'
> programming library.

Using AOP coming from OO is very much akin to using OO coming from a
procedural style of programming. There is nothing stopping you from
writing OO code using plain C, as Gnome attempts, but the power of OO is
unleashed when formally specified in languages like C++ and Java. 

This analogy applies to AOP as well. You can do AOP-like things with XML
and bytecode voodoo or using purely programmatic tools like AspectWerkz
but when you need to do some interesting things these tools are limited
compared to AspectJ. Method advice, or interceptors, are generally used
to showcase the power of AOP but generally a lot of times it's total
overkill as using a decorator or chain of responsibility will work where
people try and use method advice. Like web request processing, you don't
need interceptors and it's total overkill and a misuse of AOP. That's
just one example.

I'm not familiar at all with AspectWerkz but the really interesting
stuff in AOP comes from the combination of inter-type declarations, or
open classes, combined with advice (not just simple minded method advice
i.e. interceptors). What does that gibberish mean? Well inter-type
declarations allow you to actually change class hierarchies or add new
methods, constructors, or fields to a class.

So the typical example of what you might do here is to take a normal
POJO and modify it using aspects that it can be persisted. So in an
aspect you might add whatever methods you need to persist the POJO, add
a field to indicate a "dirty" state, and additionally add some advice to
set that "dirty" flag every time a field is modified in the POJO. I
don't know how easy this is with AspectWerkz or anything else but it's
trivial in AspectJ.

The power of AspectJ comes from its rich way of defining aspects. This,
of course, is only my opinion but I highly recommend AspectJ. One of the
other things people like to complain about with respect to AspectJ is
that runtime weaving of aspects is not there. Well, frankly, most of the
time who cares this really isn't that important but even so the 1.2
version of AspectJ is attempting to remedy this. Almost everything
useful can be done as compile time. I've seen nifty demos of weaving
security mechanisms in and out of systems at runtime but that's not
typical.

Anyway, that's my take :-)

-- 
jvz.

Jason van Zyl
[EMAIL PROTECTED]
http://maven.apache.org

happiness is like a butterfly: the more you chase it, the more it will
elude you, but if you turn your attention to other things, it will come
and sit softly on your shoulder ...

 -- Thoreau 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to