From: Daniel Berger Date: 2006-06-15T00:24:08+09:00 Subject: Re: Cut-based AOP Austin Ziegler wrote: > On 6/14/06, Ruby Newbie 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 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