ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Aspect-Oriented Programming and JBoss
Subject:   Answering your well-founded skeptism
Date:   2003-05-30 13:08:41
From:   patriot1burke
Response to: Answering your well-founded skeptism

"First, let me again prove my case that you have an education problem with AOP. Once again, my own informal poll, the only information that I have, on knowledge about AOP tells me that ZERO percent of engineers around me understand AOP. ZERO."


I agree that there is an education problem, but it is not as bad as you think. I recently gave a JBoss presentation at the NEJUG in front of about 400 people. I spent about 1-2 slides on JBoss 4 and AOP out of 60. I was hit with a flood of questions by about 5-10% of the audience. Not questions like, "what is AOP?" but rather, "How are you applying it?" "How did you implement it?" "Are you using AspectJ?" "Why not?" etc.


I thank you for your literary critism and will take them into account the next time I write an AOP article.


"* Engineers will forget the aspects because they aren't right in their face, and will spend days searching for bugs in one class when they are really in an aspect in some other distant corner of the program.


You missed the point. Aspects can INVISIBLY insert code from other areas of the program into your code. This is disconcerting at best. It's also a pain to debug as you invoke a method in one place then attempt to trace into that method invocation and crash before you get there. Why? Because an aspect has patched the method invocation in the byte code."


We only weave enough byte code so that it can hook into the framework. All the inserted bytecode does is package the method arguments into an object array and passes it along to a AOP framework class that manages the interception.


All aspects are written as Java objects, so you will be able to see these interceptors in stack traces when exceptions are thrown. Since the bytecode insertion is very minimal this will stabalize quite quickly if it hasn't already. And you can still step through with a debugger.


"* You can be working on a system without robust unit tests (like 99% of the systems in production) change an aspect and break pieces of the code you didn't even know about.
* I can imagine having to impose and 'aspect lockdown' well in advance of a code freeze so that system wide changes are not made close to release.


These two address the system-wide changing nature of AOP which is unique to AOP. When you change a base class in OOP you can understand readily the number of test cases you are having an impact on. The same is not so clear on wide-spread aspects."


If this is a worry, refrain from defining pointcuts using a generic regular expression. Or maybe regular-expression based pointcuts should be removed from the framework entirely?


Use metatags to trigger the application of an interceptor rather than a pointcut. With JBoss AOP, you can use XDoclet at first (then later JSR-175 when its ready to) to articulate behavior and bind aspects implicitly.


i.e.


/**
*
* @jboss-aop.meta-tag group="transaction" trans-attribute="RequiresNew"
*/
public void someMethod() {...}

The above would trigger the addition of a transaction interceptor


But, yes, until you can right-click on a pointcut definition within an IDE and find out what classes are affected, then some aspects ;-p of AOP will have some disadvantages(we're working on Eclipse integration as well). Until then, at least with JBoss-AOP, you'll have to find out how aspects are glued at runtime through our management console.


""Its good practice and helps me refine the message." - Ok, but what is the message? "Here is some code?" Read it and be in awe? Messaging and articles are supposed to inform and educate. The important part is the Times New Roman bits stuck between the code fragments. The code is meant to be an illustration!"


One is no less important than the other.


I learn by example, I teach by example. The example in the article is the cross-cutting concern of tracing. I apologize if you don't find my Times New Roman up-to-par. I will try to do better next time.


Bill




1 to 1 of 1
  1. Answering your well-founded skeptism
    2003-05-31 09:39:38  anonymous2 [View]

    • Answering your well-founded skeptism
      2003-07-02 02:17:35  anonymous2 [View]

      • Answering your well-founded skeptism
        2003-08-04 14:45:03  anonymous2 [View]

    • Answering your well-founded skeptism
      2003-06-02 04:58:15  anonymous2 [View]

      • Answering your well-founded skeptism
        2003-06-03 02:56:56  anonymous2 [View]

        • Answering your well-founded skeptism
          2003-06-03 09:00:25  anonymous2 [View]

1 to 1 of 1