Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Cut-based AOP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 28 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ruby Newbie  
View profile  
 More options Jun 13 2006, 10:09 pm
From: "Ruby Newbie" <rubynew...@gmail.com>
Date: Wed, 14 Jun 2006 11:09:13 +0900
Local: Tues, Jun 13 2006 10:09 pm
Subject: Re: Cut-based AOP

Curious about AOP in Ruby, I've downloaded the Cut patch for 1.8.3,
installed gperf, and am trying to understand a few things.  But - the Cut
RCR thread appears to have died.  From comments about the RCR, the voting
appears to be positive - something like 10 votes for and 2 against.  Not
being familiar with the RCR process - is Cut going to see the light of day?
Has another AOP RCR or library been proposed which has captured mind share
bringing a premature end to Cut?  Are the majority of Ruby developers
seeking to use AOP satisfied with aspectr?

On 10/24/05, Trans <transf...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 13 2006, 11:10 pm
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Wed, 14 Jun 2006 12:10:58 +0900
Local: Tues, Jun 13 2006 11:10 pm
Subject: Re: Cut-based AOP
On 6/13/06, Ruby Newbie <rubynew...@gmail.com> wrote:

> Curious about AOP in Ruby, I've downloaded the Cut patch for 1.8.3,
> installed gperf, and am trying to understand a few things.  But - the Cut
> RCR thread appears to have died.  From comments about the RCR, the voting
> appears to be positive - something like 10 votes for and 2 against.  Not
> being familiar with the RCR process - is Cut going to see the light of day?
> Has another AOP RCR or library been proposed which has captured mind share
> bringing a premature end to Cut?  Are the majority of Ruby developers
> seeking to use AOP satisfied with aspectr?

I have yet to need AOP in Ruby. Of any sort.

Others may have other opinions, but I'm not sure that it's necessary.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Schierbeck  
View profile  
 More options Jun 14 2006, 4:57 am
From: Daniel Schierbeck <daniel.schierb...@gmail.com>
Date: Wed, 14 Jun 2006 17:57:59 +0900
Local: Wed, Jun 14 2006 4:57 am
Subject: Re: Cut-based AOP

Austin Ziegler wrote:
> I have yet to need AOP in Ruby. Of any sort.

I think AOP is just what we need. Currently, it's difficult to combine
different extensions of the current behavior (e.g. transforming and
validating attributes -- they often both overwrite `#{attr}='). I'm not
sure we need the full-fledged Cut version, I think a different `def'
would suffice. Perhaps `aspect'? Well, I'm not really fluid in the AOP
lingo.

   1 class Module
   2   def attr_transformer(*attrs, &block)
   3     attrs.each do |attr|
   4       define_method("#{attr}=") do |value|
   5         instance_variable_set("@#{attr}", block.call(value))
   6       end
   7     end
   8   end
   9
  10   def attr_validator(*attrs, &block)
  11     attrs.each do |attr|
  12       define_method("#{attr}=") do |value|
  13         if block.call(value)
  14           instance_variable_set("@#{attr}", value)
  15         else
  16           raise ArgumentError, "invalid value"
  17         end
  18       end
  19     end
  20   end
  21 end

How would one use #attr_transformer and #attr_validator together?
Ideally, you could do this:

   class Module
     def attr_transformer(*attrs, &block)
       attrs.each do |attr|
         define_aspect("#{attr}=") do |value|
           # call the previously defined method, or
           # super, if none exist.
           previous(value)
         end
       end
     end

     def attr_validator(*attrs, &block)
       attrs.each do |attr|
         define_aspect("#{attr}=") do |value|
           if block.call(value)
             previous(value)
           else
             raise ArgumentError, "invalid value"
           end
         end
       end
     end
   end

   class Foo
     attr_accessor(:bar, :baz)
     attr_transformer(:bar){|value| value ** 2}
     attr_validator(:bar){|value| value > 0 and value < 10}
   end

   foo = Foo.new
   foo.bar = 3

The following would then happen:

   1.  The aspect defined by #attr_validator will be called.
   2.  The aspect defined by #attr_transformer will be called
   3.  The method defined by #attr_accessor will be called

Of course, one could just make do with a `previous' keyword in the
normal method definitions.

Cheers,
Daniel


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Schierbeck  
View profile  
 More options Jun 14 2006, 5:28 am
From: Daniel Schierbeck <daniel.schierb...@gmail.com>
Date: Wed, 14 Jun 2006 18:28:45 +0900
Local: Wed, Jun 14 2006 5:28 am
Subject: Re: Cut-based AOP

Daniel Schierbeck wrote:
>     def attr_transformer(*attrs, &block)
>       attrs.each do |attr|
>         define_aspect("#{attr}=") do |value|
>           # call the previously defined method, or
>           # super, if none exist.
>           previous(value)

That should of course be `previous(block.call(value))'...

Daniel


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 8:48 am
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Wed, 14 Jun 2006 21:48:30 +0900
Local: Wed, Jun 14 2006 8:48 am
Subject: Re: Cut-based AOP
On 6/14/06, Daniel Schierbeck <daniel.schierb...@gmail.com> wrote:

> Austin Ziegler wrote:
> > I have yet to need AOP in Ruby. Of any sort.
> I think AOP is just what we need.

I don't.

> Currently, it's difficult to combine
> different extensions of the current behavior (e.g. transforming and
> validating attributes -- they often both overwrite `#{attr}='). I'm not
> sure we need the full-fledged Cut version, I think a different `def'
> would suffice. Perhaps `aspect'? Well, I'm not really fluid in the AOP
> lingo.

Then don't *use* those. And, honestly, I have always felt that AOP is
a solution looking for a real problem. I can *sort* of understand it
in Java, but there you have bytecodes to modify. In Ruby, however, I
think that there are other (better) mechanisms, and Matz has suggested
that we *will* have :pre and :post in Ruby 2.0.

[...]

> How would one use #attr_transformer and #attr_validator together?

I wouldn't.

>    class Foo
>      attr_accessor(:bar, :baz)
>      attr_transformer(:bar){|value| value ** 2}
>      attr_validator(:bar){|value| value > 0 and value < 10}
>    end

I wouldn't write it that way.

  class Foo
    attr_accessor :bar
    remove_method :bar= ;
    def bar=(val) #:nodoc:
      raise ArgumentError unless (value > 0 and value < 10)
      @bar = val ** 2
    end
  end

Or I'd look at using Ara's "traits" library (bad name, interesting
library that so far I haven't needed).

Your example is a particularly bad one because it's the space that
*should* be handled by methods. But (IMO) you shouldn't want to build
your code in the way that you have just done; it divides the code very
badly.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Schierbeck  
View profile  
 More options Jun 14 2006, 8:59 am
From: Daniel Schierbeck <daniel.schierb...@gmail.com>
Date: Wed, 14 Jun 2006 21:59:12 +0900
Local: Wed, Jun 14 2006 8:59 am
Subject: Re: Cut-based AOP

Austin Ziegler wrote:
> On 6/14/06, Daniel Schierbeck <daniel.schierb...@gmail.com> wrote:
>> Austin Ziegler wrote:
>> > I have yet to need AOP in Ruby. Of any sort.
>> I think AOP is just what we need.

> I don't.

Then I guess we disagree.

Daniel


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
transf...@gmail.com  
View profile  
 More options Jun 14 2006, 9:11 am
From: transf...@gmail.com
Date: Wed, 14 Jun 2006 22:11:22 +0900
Local: Wed, Jun 14 2006 9:11 am
Subject: Re: Cut-based AOP

Austin Ziegler wrote:
> On 6/13/06, Ruby Newbie <rubynew...@gmail.com> wrote:
> > Curious about AOP in Ruby, I've downloaded the Cut patch for 1.8.3,
> > installed gperf, and am trying to understand a few things.  But - the Cut
> > RCR thread appears to have died.  From comments about the RCR, the voting
> > appears to be positive - something like 10 votes for and 2 against.  Not
> > being familiar with the RCR process - is Cut going to see the light of day?
> > Has another AOP RCR or library been proposed which has captured mind share
> > bringing a premature end to Cut?  Are the majority of Ruby developers
> > seeking to use AOP satisfied with aspectr?

> I have yet to need AOP in Ruby. Of any sort.

Well, saying that is sort-of like programming Turbo Pascal in the 80's
and saying "I have yet to need OOP". AOP is not just a little side
utility, it's a whole new angle on coding. Have a look at this:

http://mail.python.org/pipermail/python-list/2003-November/193337.html

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simen Edvardsen  
View profile  
 More options Jun 14 2006, 9:22 am
From: "Simen Edvardsen" <toal...@gmail.com>
Date: Wed, 14 Jun 2006 22:22:52 +0900
Local: Wed, Jun 14 2006 9:22 am
Subject: Re: Cut-based AOP
On 6/14/06, transf...@gmail.com <transf...@gmail.com> wrote:

Well, you could just go Functional Programming All the Way (tm). Not
my preference, but still.

> AOP is not just a little side
> utility, it's a whole new angle on coding. Have a look at this:

> http://mail.python.org/pipermail/python-list/2003-November/193337.html

I don't think this sheds much light on AOP as applied to Ruby. At
least I got confused by the Java-like syntax (with such a verbose
language no doubt you'd want something like this) and the fact that
all the samples seem longer and more cumbersome than the "standard"
way of doing this, while not adding much value. I imagine much of this
could be done with some metaprogramming.

I'm happy with the pre and post hooks planned for 2.0.

> T.

--
- Simen

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Francis Cianfrocca  
View profile  
 More options Jun 14 2006, 9:35 am
From: "Francis Cianfrocca" <garbageca...@gmail.com>
Date: Wed, 14 Jun 2006 22:35:35 +0900
Local: Wed, Jun 14 2006 9:35 am
Subject: Re: Cut-based AOP

>>>Well, saying that is sort-of like programming Turbo Pascal in the 80's

and saying "I have yet to need OOP". AOP is not just a little side
utility, it's a whole new angle on coding. <<<

I'm looking for ways to put *harder* shells around pieces of well-tested and
well-designed functionality, not for ways to slice them open even more. The
article you cite makes a big deal out of "loose-coupling" (the buzzword of
the decade) as a goal for AOP. I'd rather accomplish that with asynchronous
messaging.

Austin is right, we don't need AOP.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
transf...@gmail.com  
View profile  
 More options Jun 14 2006, 10:22 am
From: transf...@gmail.com
Date: Wed, 14 Jun 2006 23:22:07 +0900
Local: Wed, Jun 14 2006 10:22 am
Subject: Re: Cut-based AOP

Francis Cianfrocca wrote:
> >>>Well, saying that is sort-of like programming Turbo Pascal in the 80's
> and saying "I have yet to need OOP". AOP is not just a little side
> utility, it's a whole new angle on coding. <<<

> I'm looking for ways to put *harder* shells around pieces of well-tested and
> well-designed functionality, not for ways to slice them open even more. The
> article you cite makes a big deal out of "loose-coupling" (the buzzword of
> the decade) as a goal for AOP. I'd rather accomplish that with asynchronous
> messaging.

> Austin is right, we don't need AOP.

One can argue the merits (or lack there-of) of AOP all you want. But I
think you and Audtin are being overbarring to tell others they don't
need AOP. That's not your choice. And I don't see Ruby as something so
draconian. There is nothing adverse to the ability to,

  require 'cuts'

if one so chooses.

Implementation unfortuately is a bit tricky, and a pure Ruby
implementation is impossible, but it's not that far off, and I'm sure
if Matz and Peter Vanbroekhoven got together they could iron out a way
for it to be reasonably implemented as an optional .so. Any way you
slice it, Ruby can only benefit from such analystic work.

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 10:44 am
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Wed, 14 Jun 2006 23:44:13 +0900
Local: Wed, Jun 14 2006 10:44 am
Subject: Re: Cut-based AOP
On 6/14/06, transf...@gmail.com <transf...@gmail.com> wrote:

> Austin Ziegler wrote:
> > On 6/13/06, Ruby Newbie <rubynew...@gmail.com> wrote:
> > > Curious about AOP in Ruby, I've downloaded the Cut patch for 1.8.3,
> > > installed gperf, and am trying to understand a few things.  But - the Cut
> > > RCR thread appears to have died.  From comments about the RCR, the voting
> > > appears to be positive - something like 10 votes for and 2 against.  Not
> > > being familiar with the RCR process - is Cut going to see the light of day?
> > > Has another AOP RCR or library been proposed which has captured mind share
> > > bringing a premature end to Cut?  Are the majority of Ruby developers
> > > seeking to use AOP satisfied with aspectr?
> > I have yet to need AOP in Ruby. Of any sort.
> Well, saying that is sort-of like programming Turbo Pascal in the 80's
> and saying "I have yet to need OOP". AOP is not just a little side
> utility, it's a whole new angle on coding. Have a look at this:

Nice article. It is, as a follow-up message said, the best
introduction to AOP that I've seen.

I *still* don't see the value in it. Instead, I see significant
problems with the maintainability of such code.

IMO, AOP exists primarily because of the limitations of Java.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ruby Newbie  
View profile  
 More options Jun 14 2006, 10:45 am
From: "Ruby Newbie" <rubynew...@gmail.com>
Date: Wed, 14 Jun 2006 23:45:50 +0900
Local: Wed, Jun 14 2006 10:45 am
Subject: Re: Cut-based AOP

transfire - from your response, it would seem that AOP for ruby is alive and
kicking - is work moving forward to include Cut within Ruby proper?  If so,
would you expect it in a 1.8.x release or later?

On 6/14/06, transf...@gmail.com <transf...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 10:46 am
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Wed, 14 Jun 2006 23:46:56 +0900
Local: Wed, Jun 14 2006 10:46 am
Subject: Re: Cut-based AOP
On 6/14/06, transf...@gmail.com <transf...@gmail.com> wrote:

> One can argue the merits (or lack there-of) of AOP all you want. But I
> think you and Audtin are being overbarring to tell others they don't
> need AOP. That's not your choice. And I don't see Ruby as something so
> draconian. There is nothing adverse to the ability to,

Excuse me. I didn't say that others don't need AOP. I said that *I*
haven't needed AOP in four years of Ruby experience and it seems to
offer no value over what Ruby already offers.

Yes, I'm one of the folks who is "strongly opposed" to the cut-based
AOP RCR that you've written. I think it's unnecessarily complex and
there are better and more-established ways of offering such
extensibility.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 10:50 am
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Wed, 14 Jun 2006 23:50:15 +0900
Local: Wed, Jun 14 2006 10:50 am
Subject: Re: Cut-based AOP
On 6/14/06, Ruby Newbie <rubynew...@gmail.com> wrote:

> transfire - from your response, it would seem that AOP for ruby is alive and
> kicking - is work moving forward to include Cut within Ruby proper?  If so,
> would you expect it in a 1.8.x release or later?

1. Cut-based AOP for Ruby is neither alive nor dead. Matz has neither
accepted nor rejected the RCR that trans proposed. I personally think
that it's overengineered for too little value. That should surprise no
one.

2. Matz is the only one who would be able to indicate such a change as
"alive"; not trans, not me, not anyone else.

3. Even if it is accepted, it will not see the light of day
(officially) until Ruby 2.0 or later. It will never be in a 1.8.x
release because it's a major change.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ruby Newbie  
View profile  
 More options Jun 14 2006, 10:57 am
From: "Ruby Newbie" <rubynew...@gmail.com>
Date: Wed, 14 Jun 2006 23:57:53 +0900
Local: Wed, Jun 14 2006 10:57 am
Subject: Re: Cut-based AOP

Austin,

Looking around, you have hundreds of posts, and you're involved as a mentor
in Google Summer of Code " Automated Wrapper Generation for Information
Extraction" arena.  I take it you have the experience to back up what you're
saying.

Can you provide references to better and more-established ways of offering
such
extensibility?  I looked briefly at traits which you'd alluded to earlier,
but it requires changes to the core code for trait/hook insertion.  I'm
interested to read about other mechanisms which are more maintainable and
extensible than AOP in Ruby if you could please share them.

I ask not to inflame, but to draw out an open discourse around this matter.

On 6/14/06, Austin Ziegler <halosta...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Francis Cianfrocca  
View profile  
 More options Jun 14 2006, 11:03 am
From: "Francis Cianfrocca" <garbageca...@gmail.com>
Date: Thu, 15 Jun 2006 00:03:45 +0900
Local: Wed, Jun 14 2006 11:03 am
Subject: Re: Cut-based AOP

>>>One can argue the merits (or lack there-of) of AOP all you want. But I

think you and Audtin are being overbarring to tell others they don't
need AOP. That's not your choice. <<<

Cool, I'm willing to be proved wrong. Hack it into Ruby so I can try it
(patch the language if you have to- Lord knows I've done that enough times),
write up the use cases with working examples in non-trivial programs, and
show how it's better than competing approaches.

It seems to me that Ruby has enough extensibility built in today, so that
with an IoC/DI approach you could do everything you can with AOP. But here
(and elsewhere) AOP is being presented as a new style of programming with
unique value, and that is far from convincing at the moment. I can see the
value of adding crosscuts (and DI) for system management and debugging
support, but not for extending application functionality. Until proven
otherwise, I'm going with my intuition that this is an excellent way to make
complex systems even more complex, fragile, and hard to manage.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 11:20 am
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Thu, 15 Jun 2006 00:20:13 +0900
Local: Wed, Jun 14 2006 11:20 am
Subject: Re: Cut-based AOP
On 6/14/06, Ruby Newbie <rubynew...@gmail.com> wrote:

> Looking around, you have hundreds of posts, and you're involved as a
> mentor in Google Summer of Code "Automated Wrapper Generation for
> Information Extraction" arena. I take it you have the experience to
> back up what you're saying.

I like to think I do, at least. I will freely admit that I don't "get"
AOP. I *understand* the reasons for AOP (adding logging for something
you no longer necessarily have source access to, for example), but I
have *long* felt that AOP is a pure hack.

> Can you provide references to better and more-established ways of
> offering such extensibility?  I looked briefly at traits which you'd
> alluded to earlier, but it requires changes to the core code for
> trait/hook insertion.  I'm interested to read about other mechanisms
> which are more maintainable and extensible than AOP in Ruby if you
> could please share them.

If you control the source, write the source better. If you *want*
extensibility points, provide clear hooks.

  class Foo
    def bar
      pre_baz if respond_to? :pre_baz
      baz
      post_baz if respond_to? :post_baz
    end
  end

Matz will be providing (somewhat) cleaner ways to do this, but that's
the essential nature of the beast. It's a form of plugin-style
programming and that's well understood, while AOP is a poorly defined
and easily misunderstood beast.

Similarly, mixins provide the main capability that Ruby needs -- but the
original programmer has to write the code to be able to deal with this
properly. And if they don't, you can always inherit or compose.

I think that it's important to note that *even now* (five years on from
the PARC research) you can't find many clearly-written, concise
explanations of AOP and why you'd want it. It's all buzzwords.

AOP may be valuable. But I have yet to see anything that convinces me
that it's worth all the bother. It's sort of like Inversion of Control.
Interesting, but not relevant to most (98%+) needs.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Berger  
View profile  
 More options Jun 14 2006, 11:24 am
From: Daniel Berger <djber...@gmail.com>
Date: Thu, 15 Jun 2006 00:24:08 +0900
Local: Wed, Jun 14 2006 11:24 am
Subject: Re: Cut-based AOP

What about taking this concept and applying it to the great Unicode debate?

# Pseudocode
class String
    def pre
       self.replace(MultiToWide(self)) if TextIsUnicode(self)
    end
end

Maybe smarter minds than I could take this idea further.

Regards,

Dan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Mahurin  
View profile  
 More options Jun 14 2006, 12:10 pm
From: "Eric Mahurin" <eric.mahu...@gmail.com>
Date: Thu, 15 Jun 2006 01:10:29 +0900
Local: Wed, Jun 14 2006 12:10 pm
Subject: Re: Cut-based AOP
On 6/14/06, Ruby Newbie <rubynew...@gmail.com> wrote:

> Can you provide references to better and more-established ways of offering
> such
> extensibility?  I looked briefly at traits which you'd alluded to earlier,
> but it requires changes to the core code for trait/hook insertion.  I'm
> interested to read about other mechanisms which are more maintainable and
> extensible than AOP in Ruby if you could please share them.

Here is a way to get 99% of this cut-based AOP thing (that is
overengineered as Austin says):

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/29...

All you need is Object#become from evil.rb.  You could write a few
wrappers to make this look prettier.

I think if some AOP thing is added to ruby, it should be something
very simple that could be extended to some elaborate AOP framework
(rather than starting with an elaborate framework as trans suggested -
that includes new keywords!).  Here are some of the simple things that
could be used as a a basis for AOP:

- pre and post method hooks (what matz is planning)

- Object#become/Class#replace.  Can be implemented now in pure ruby (evil.rb)

- something like Module#include except "super" (or something else) in
the included methods refers to the previous method definition.

Eric


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
transf...@gmail.com  
View profile  
 More options Jun 14 2006, 12:38 pm
From: transf...@gmail.com
Date: Thu, 15 Jun 2006 01:38:01 +0900
Local: Wed, Jun 14 2006 12:38 pm
Subject: Re: Cut-based AOP

Try reading some back posts. This has been proposed countless times.
It's flawed.

You know, it's easy to spout YAGNI and AYRHTDI (All Your Really Have To
Do Is) and such. It's whole nother story when you actaully WORK on it.
Try spending two years studying AOP and how it could work in Ruby and
then get back to me. There's more to it than you understand.

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Ziegler  
View profile  
 More options Jun 14 2006, 12:54 pm
From: "Austin Ziegler" <halosta...@gmail.com>
Date: Thu, 15 Jun 2006 01:54:34 +0900
Local: Wed, Jun 14 2006 12:54 pm
Subject: Re: Cut-based AOP
On 6/14/06, transf...@gmail.com <transf...@gmail.com> wrote:

> You know, it's easy to spout YAGNI and AYRHTDI (All Your Really Have To
> Do Is) and such. It's whole nother story when you actaully WORK on it.
> Try spending two years studying AOP and how it could work in Ruby and
> then get back to me. There's more to it than you understand.

If it takes two years of studying to "get" AOP, then I definitely *do
not* need it. IOC is easier to understand than that, and I think that
it has more value in Ruby than what I've understood of AOP.

AOP *may* be a revolution in programming, but *no one* has been able
to explain its real and immediate value to me in any way. I didn't do
OOP for years, but I *got* it very quickly when I was taught it.

Here's the challenge. Let's accept, for the moment, that your RCR
represents the Right Way to do AOP in Ruby. Now, convince me that we
need your RCR. Sell me on AOP. Tell me what the benefits are -- *show*
me the benefits in code. Show me that my code will be shorter, easier
to understand, cleaner, more extensible, more secure, *whatever* with
AOP. Right now, if I want to give someone hooks into my code, I make
explicit plugin points. If I don't and someone wants to modify either
the input or output of my method, then they can either wrap me through
inheritance or composition. I really do *not* get the value that AOP
gives me, and the example given in the Python mailing list link you
gave me is clever, but I can't see *value* there.

We've had a discussion recently. *Convince* me that AOP will make a
Ruby developer's life significantly better than what I have described
("plugin points", inheritance/composition wrapping) as well-understood
and I'll support you. My problem isn't with your RCR; my problem is
with AOP. Right now, it's just a buzzword with little value. If it has
value, I am convinced that you can change my opinion.

-austin
--
Austin Ziegler * halosta...@gmail.com * http://www.halostatue.ca/
               * aus...@halostatue.ca * http://www.halostatue.ca/feed/
               * aus...@zieglers.ca


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ruby Newbie  
View profile  
 More options Jun 14 2006, 1:00 pm
From: "Ruby Newbie" <rubynew...@gmail.com>
Date: Thu, 15 Jun 2006 02:00:51 +0900
Local: Wed, Jun 14 2006 1:00 pm
Subject: Re: Cut-based AOP

Thanks Eric.  As I see evil.rb, and Object#become - we're basically looking
at object inheritance, which may get the job done in some cases, but
violates the separation which AOP is attempting to provide/enforce.  I'm new
to AOP as well as Ruby, but strictly from an OOP persepective, I don't want
to assume the responsibility for all methods of the parent for the purpose
at hand - behavior monitoring / modification of 1-n methods of the class.

On 6/14/06, Eric Mahurin <eric.mahu...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Pollak  
View profile  
 More options Jun 14 2006, 1:29 pm
From: "David Pollak" <pol...@gmail.com>
Date: Thu, 15 Jun 2006 02:29:12 +0900
Local: Wed, Jun 14 2006 1:29 pm
Subject: Re: Cut-based AOP

Folks,

Aspects are bad (but perhaps a necessary evil in Java) and Ruby doesn't need
them.

Aspects provide a theoretically interesting facility to insert code around
methods or around calls to methods.  They provide meta-programming
facilities to Java, a language that was designed for type-safety and without
meta-programming in mind.

In my experience, Aspects have been used by Java developers during
development/debugging to "figure out what's going on" with calls to
particular methods.  Aspects provide a nice set of runtime debugging tools
that allow the developer to trap and trace particular calls and/or call
patterns in a way that simply setting a breakpoint cannot do.  Aspects work
pretty well for this application.

Aspects are also used to add "features" to existing classes.  The
prototypical use in my experience is to add transactions into a series of
JDBC (database) calls that didn't have transactions before.  To the extend
that the source code for the original libraries is unavailable or infeasible
to change, Aspects work okay to patch code.

However, Java's execution model and gestault revolve around execution
predictability.  Once I write, test, and deploy a class, the execution of
the class and its side effects are knowable and verifiable.  This is good
from a security and testing standpoint.  This is perhaps Java's greatest
strength for large-scale projects.  Aspects destroy this model and
fundimentally weaken Java.  Depending on the Aspects in use during
development, during testing, and during deployment, execution of well tested
code can change and not work correctly.  The model for describing Aspects is
broken and can lead to over-broad application of an Aspect such that code is
unintentionally broken because of the way an Aspect is described.

Ruby doesn't need Aspects.  Ruby's open class structure means that any code
can perform necessary surgery on an existing class in a well defined, well
understood fashion.  Ruby's meta-programming facilities (alias_method, open
classes, etc.) allow a Ruby developer to wrap methods from other classes,
redirect execution, etc. in a predictable, programmatic fashion.  Ruby has
the meta-programming facilities to provide method wrapping, logging,
performance monitoring, etc.

My 2 cents.

Thanks,

David

On 6/14/06, Austin Ziegler <halosta...@gmail.com> wrote:

--
--------
David Pollak's Ruby Playground
http://dppruby.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
transf...@gmail.com  
View profile  
 More options Jun 14 2006, 2:17 pm
From: transf...@gmail.com
Date: Thu, 15 Jun 2006 03:17:14 +0900
Local: Wed, Jun 14 2006 2:17 pm
Subject: Re: Cut-based AOP

Ha ha! You're funny Austin. It took over 20 years for OOP to gain
acceptance. 20 years! You expect me to do the same for AOP in a couple
of mailing list posts? The success of OOP grew out hands on work with
it's concepts. The success, or failure, of AOP will only come about in
the same way. Of course if we never have good tools for working with
AOP how will we ever know?

While everyone's busy bashing AOP, other people are trying to see what
*orthoginal design* can do. It would be nice if we could use Ruby to do
the same and with a solid foundation like cuts (which again would be an
optional library).

But to play along a bit you might be interested to know that the whole
reason I got into AOP is because I started doing AOP before I even knew
what is was or that the concepts were already out there. Perhaps you
recall GUtopIa? Well, that was a GUI framework I wanted to build for
Ruby. The way I wanted it to work required method-wrapping entire
classes! After some nasty meta-coding that would make most people's
eyes pop out, I started to thinking I needed some kind framework, and
lo, I discovered the concepts were already out there in AOP. I put
GUtopIa on the back burner and decided to pursue AOP for Ruby with the
ultimate hope of returning to GUtopIa when good AOP support was in
hand. That's how the Cut-based AOP RCR got developed. It wasn't just an
abstraction pulled out of the thin air. Thankfully I met Peter
Vanbroekhoven, an monumentally capable coder, and together we spent
nearly two years studying AOP concepts and hammering out possibilites.
What we ended up with, while perhaps not perfect (is anything ever
perfect?) is a clean foundational system that supports all the
requirements of AOP without forcing anyone into a specialized
high-level way of doing things --you are free to abtract to top of it
as *you* see fit.

Seems like a good deal to me.

T.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Molitor, Stephen L  
View profile  
 More options Jun 14 2006, 3:16 pm
From: "Molitor, Stephen L" <Stephen.L.Moli...@erac.com>
Date: Thu, 15 Jun 2006 04:16:47 +0900
Local: Wed, Jun 14 2006 3:16 pm
Subject: Re: Cut-based AOP
For what it's worth (not much), I'll share my perspective on this.  At
work I'm an 'enterprise' Java developer.  Did C++ / Tuxedo before that.
At home I use Ruby a lot.  At one point I was pretty keen on AOP and
even developed a little framework for PicoContainer that integrated Pico
with DynaAop and Groovy.  Committed it, never actually used it myself.
My work project switched from Pico to the Spring framework.  

We use Spring for dependency injection and AOP.  We use Spring AOP for
one thing.  No, not logging - we use it for transactions.  In Java AOP
is nice for that.  But even there, the whole Spring thing is
complicated.  When I try to explain that Spring is complicated to folks
at work, people look at me like I'm a little dim-witted.  Poor Steve, if
he can't handle Spring, how would he ever have coped back in the day,
when we did EJB?  Now that was configuration for real men.

But in the Ruby (and Rails) world, things are a *lot* more
straightforward.  I don't miss my DI or AOP config files at all.  99% of
the time DI is used to make it easier to mock things out for testing.
But in Ruby classes are modifiable objects.  So you can just plug a
different implementation of the new factory method, or plug in new
defitions of the problematic methods, or subclass the problem thing in
the test, or what have you.  I'm probably missing some options.  But
I've never found hard to mock stuff out for testing.

I'm not sure we would need AOP for transactions as much in Java if there
was a nicer syntax for anonymous classes.  Passing a block to File.open
or Transaction.execute in Ruby is so straightforward.  As for as
introduction goes, well I have felt the need in Java on occasion to
mixin in a class.  Not so strong a need that I reached for AOP to do it,
but it would be nice.  Again though, Ruby has mixins and open classes,
so no real need.  It would be nice to have some sort of namespace
selector mechanism so that you could apply introductions just to certain
scopes.  Beyond that though, I'm good.

A few times I have aliased a method in Ruby and had the new method
definition call the old.  Simple, but it can feel a bit hackery.  I like
the idea of pre/post and around advice constructs.  I'm familiar with
that from Lisp, and it didn't seem to destroy the language or anything.

Although I might word it a bit more softly, I tend to agree with Austin
-- Ruby doesn't need AOP, at least not too much beyond what it already
has.  The only minor things that I might like added are already being
discussed for Ruby 2.  I wouldn't want anything too fancy added to the
language itself or the standard library.  Simple is good.

Steve


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 28   Newer >
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google