Article:
  Aspect-Oriented Programming and JBoss
Subject:   Answering your well-founded skeptism
Date:   2003-05-30 07:22:47
From:   patriot1burke
Response to: Answering your well-founded skeptism

""Will you be able to determine what is actually going on?" - I can see it right now. A couple of months into the the project everyone is happy. AOP is running cool and snappy. Then at crunch time when the bugs are flying around like mad people will be banging their heads into walls trying to figure out "what is actually going on", and ripping out aspects left and right to get back to "real code"."


We've written a GUI management console so that you can see what aspects have been applied to any given class at runtime. Many of the aspects we're writing for JB4 are triggered by metatags declared using XDoclet tags right in the source. GUI + declarative XDoclet tags bring aspects out right in the open.


"I just looked up "Apsect Oriented Programming" on the MSDN, "No Topics Found"."


You didn't look hard enough. http://msdn.microsoft.com/msdnmag/issues/02/03/AOP/default.aspx


"* Maintenance programmers won't know AOP from ASP and will reak havoc.
* 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 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."


PLEASE! Replace aspect or AOP with your favorite methodology (OOP etc..), acronym (EJB, CORBA), or language (C++, Python, Java) and you can apply the generalized statements you make above really to anything in software development.


But other statements, I will address.


"* You can have hairy aspect ordering problems."


Yes this is an issue. JBoss AOP provides some mechanisms for this, other AOP frameworks do the same. Go to our website or another AOP frameworks' website.


"* There are issues getting aspects to talk between each other."


Not a problem with JBoss AOP at least with a single full remote or local invocation which is why we have an Invocation and InvocationResponse object in the first place. ThreadLocals are also useful as well.


"* Aspects can cross component boundaries freely, with adverse effect."


Then don't use a regular expression to apply your aspects and/or rely on pointcuts triggered by metatags. Apply aspects declaratively on a per-class basis.


Although this is non-documented, in JBoss AOP we are also experimenting with the idea of an abstract AOP container so that pointcuts can be applied across groups of different instances rather than forcing pointcuts at the class level.


One of the things I wanted to drive JBoss AOP is real-world requirements. I want all functionality of JBoss AOP to be driven by use cases, not some academic ivory tower phd thesis. JBoss 4 implements a bunch of powerful aspects that have actually driven the underlying framework itself. We are currently using it also to implement EJB caching and optimized HTTP session replication. In other words, we are eating our own lunch.


I'm sorry the article did not meet your expectations. Personally, I need to see some simple examples in action before I can really understand how something can be used. When opening a tech book, I usually skip the BS in the first few chapters and go directly to the meat, but that's just me. Spare me the "blah blah blah", just show me the damn code!


On a side note, its funny. Recently, we were talking to an AOP expert who generally writes articles and papers on AOP about reviewing and making suggestions on our codebase, his response was "I'm allergic to code." I'll leave the "conceptual and architecture article"s to those allergic to code.


All and all, thanks for the exercise. Its good practice and helps me refine the message.


Bill

Full Threads Newest First

Showing messages 1 through 8 of 8.

  • Answering your well-founded skeptism
    2003-05-30 10:48:53  anonymous2 [View]

    I'll have some specific comments, but I'd like to center my response around the educational aspects of your response.

    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.

    And in the time since we have started this conversation the sun has risen and set on Japan, Australia and India, and nobody in any of those places chose to respond to your article.

    Must I make my case any more plain? You have an adoption and education problem with AOP. If you want AOP to take off it's your job as a member of the AOP community to be an advocate for the technology. Statements such as: 'Spare me the "blah blah blah", just show me the damn code!' betray a lack of understanding about your audience. You cannot assume knowledge of AOP. Period.

    The article you mention (which is not on the CD version of the MSDN):

    http://msdn.microsoft.com/msdnmag/issues/02/03/AOP/default.aspx

    Is interesting because it spends six paragraphs and a graphic explaining AOP and giving links before it "show(s) me the damn code!"

    Is there no place for a pragmatist, like yourself, to write articles on pragmatic, but high level, approaches to actually using AOP in production? Why must all of the AOP articles either be ridiculously abstract, or nose deep in th code?

    Comments or your other comments:

    Your assertion that I can "apply the generalized statements you make above really to anything in software development" is both right and wrong. These problems occur in other environments but they are more acute in AOP because nobody knows AOP. Let's look at them again, so that you can understand them before you brush them off:

    * Maintenance programmers won't know AOP from ASP and will reak havoc.

    This has a real world case in point. When the first qsort algorithm was implemented it was ripped out by maintenance engineers that didn't know what it was or how it worked. I have proven that nobody knows AOP or how it works. Thus it will be ripped out by maintenance engineers with bugs to fix.

    * 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.

    * 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.

    "One of the things I wanted to drive JBoss AOP is real-world requirements. I want all functionality of JBoss AOP to be driven by use cases, not some academic ivory tower phd thesis." - This is a good sign. Perhaps we as customers of JBoss would like to know just what those use cases are so that when can ensure that our architectures match the design that you are creating.

    "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!
    • Answering your well-founded skeptism
      2003-05-30 13:08:41  patriot1burke [View]

      "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


      • Answering your well-founded skeptism
        2003-05-31 09:39:38  anonymous2 [View]

        Ok, thanks for the conversation. I've learned a lot and you have been very tolerant of my interrogation style.
        • Answering your well-founded skeptism
          2003-06-02 04:58:15  anonymous2 [View]

          Certainly, he has been very tolerant with you!
          • Answering your well-founded skeptism
            2003-06-03 02:56:56  anonymous2 [View]

            I loved the article. First time I've understood what AOP is about (not that I have tried that hard).

            At project start up the issues are always:
            How do we do error handling
            How do we do logging
            How do we do internationalization
            How do we persist data
            How do we ensure it runs, and bounces back if it dies.

            AOP can answer quite a few of these. However, the next concern is:
            How do we make sure it works quickly and robustly.

            And here I side with the red flag - I can't see the code, and I worry like hell that it will create far more trouble for me than doing it myself with simply high level language constructs that I know work.

            So what if its a little extra typing, typing is easy.

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

              Here's a link to another interesting article on AOP, actually EAOP, that doesn't use logging as an example:

              http://www.emn.fr/x-info/sudholt/papers/tr-11-2002.pdf

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

          This is the best thread on AOP I've read so far.
          Thank you, both.

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

            I ended up with this thread not after reading the article but when I started evaluating AspectJ Vs JBoss AOP.

            I found this discussion thread very useful, it had a lot to read. I have a feeling that over the period of time JBoss AOP framework will improve in every respect. Well, I think I should get started with JBoss AOP leaving AspectJ aside.

            I am still skeptical about the ClassLoader issue, what is roadmap for JBoss AOP framework, will the class loader dependency be removed in future. How easy it would be to migrate JBoss AOP enabled Applications to other J2EE App Servers like Weblogic, WebSphere...

            I would love to see Eclipse integration, if it is already available where can I find it.

            Pardon me, if my question looks stupid.

            -Yogesh Prajapati