From: "Volkmann, Mark" Date: 2003-08-26T23:01:03+09:00 Subject: Re: Aspect oriented Everything? This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C36BDA.39CFD912 Content-Type: text/plain; charset="iso-8859-1" I'd be glad to share some examples, but unfortunately they will be examples of using AspectJ with Java. I don't have any experience with AspectR for Ruby. Here's one example. It adds code to measure the performance of all methods called "deposit" in the class "Account". A pointcut specifies places in an application that will be affected by an aspect. The ".." below means to match methods with any number of parameters of any types. Code being inserted by an aspect is called advice. An "around" advice takes the place of actual methods. The actual method can be invoked from the advice code by using the method "proceed". package com.agedwards.aspects; import com.agedwards.bank.Account; aspect PerformanceAspect { pointcut methodsToTime(): execution(void Account.deposit(..)); void around(): methodsToTime() { long startTime = System.currentTimeMillis(); proceed(); long stopTime = System.currentTimeMillis(); long elapsedTime = stopTime - startTime; System.out.println("Perf: time to deposit = " + elapsedTime + " ms"); } } I could easily measure the performance of other methods by simply changing the definition of the "methodsToTime" pointcut. I don't want to put this code in the Account class because other users of this class may not want it. -----Original Message----- From: Ben Giddings [mailto:ben@thingmagic.com] Sent: Monday, August 25, 2003 1:12 PM To: ruby-talk@ruby-lang.org Subject: Re: Aspect oriented Everything? Volkmann, Mark wrote: > However, let's talk about the use of AOP in Ruby. Suppose you implement > an aspect as a mixin and then mix that into many classes. Another > application may want to reuse those classes but they may want a > different implementation of the mixin. That will require overridding > the mixin methods which seems cumbersome. Ok, and what is the AOP alternative? Like I said, I don't know much about it, other than the brief glance I've had at it. I'd like to see a fairly simple, but concrete example of "here is a problem that needs solving, here's how you'd solve it without AOP, here's how you'd solve it with AOP." My guess is that there are other people on the list who are similarly interested, but if not, feel free to speak up and we could do this offline. Ben --------------------------------------------------------------------------------------------------------- A.G. Edwards & Sons' outgoing and incoming e-mails are electronically archived and subject to review and/or disclosure to someone other than the recipient. --------------------------------------------------------------------------------------------------------- ------_=_NextPart_001_01C36BDA.39CFD912 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: Aspect oriented Everything?

I'd be glad to share some examples, but unfortunately the= y will be examples of using AspectJ with Java.  I don't have any exper= ience with AspectR for Ruby.

Here's one example.  It adds code to measure the per= formance of all methods called "deposit" in the class "Accou= nt".  A pointcut specifies places in an application that will be = affected by an aspect.  The ".." below means to match method= s with any number of parameters of any types.  Code being inserted by = an aspect is called advice.  An "around" advice takes the pl= ace of actual methods.  The actual method can be invoked from the advi= ce code by using the method "proceed".

package com.agedwards.aspects;

import com.agedwards.bank.Account;

aspect PerformanceAspect {

  pointcut methodsToTime(): execution(void Account.d= eposit(..));

  void around(): methodsToTime() {
    long startTime =3D System.currentTime= Millis();
    proceed();
    long stopTime =3D System.currentTimeM= illis();
    long elapsedTime =3D stopTime - start= Time;
    System.out.println("Perf: time t= o deposit =3D " + elapsedTime + " ms");
  }
}

I could easily measure the performance of other methods b= y simply changing the definition of the "methodsToTime" pointcut.=   I don't want to put this code in the Account class because other use= rs of this class may not want it.

-----Original Message-----
From: Ben Giddings [mailto:ben@thingmagic.com]
Sent: Monday, August 25, 2003 1:12 PM
To: ruby-talk@ruby-lang.org
Subject: Re: Aspect oriented Everything?


Volkmann, Mark wrote:
> However, let's talk about the use of AOP in Ruby.&n= bsp; Suppose you implement
> an aspect as a mixin and then mix that into many cl= asses.  Another
> application may want to reuse those classes but the= y may want a
> different implementation of the mixin.  That w= ill require overridding
> the mixin methods which seems cumbersome.

Ok, and what is the AOP alternative?

Like I said, I don't know much about it, other than the b= rief glance
I've had at it.  I'd like to see a fairly simple, b= ut concrete example
of "here is a problem that needs solving, here's ho= w you'd solve it
without AOP, here's how you'd solve it with AOP."

My guess is that there are other people on the list who a= re similarly
interested, but if not, feel free to speak up and we cou= ld do this offline.

Ben



---------------------------------------------------------------------------= ------------------------------
A.G. Edwards & Sons' outgoing and incoming e-mails are electronically
archived and subject to review and/or disclosure to someone other
than the recipient.

---------------------------------------------------------------------------= ------------------------------
------_=_NextPart_001_01C36BDA.39CFD912--