What are Aspects? (Re: How can I make my assertions smarter?)

William Tanksley wtanksle at hawking.armored.net
Tue Nov 9 16:50:01 EST 1999


On Tue, 09 Nov 1999 01:33:46 +1300, Greg Ewing wrote:
>Aahz Maruch wrote:

>> Sounds like templates to me, or Python's "mix-in" classes.  Am I missing
>> something?

>It seems like you can apply these things after the fact to
>already-written classes. To do the same with templates or
>mixins you would have to modify the existing code.

That's the secondary idea -- you can drop an 'aspect' class into an app
and just have it work.  This is good for Debugging, Logging, Testing, or
Optimization aspects -- the code should work both with and without them,
and it should be possible to add them without disturbing the originals.

The _primary_ idea, though, is that aspects can contain functionality
which classes simply can't.  In order to implement reference counting with
classes, for example, you have to modify tons of source code by hand, all
in seperate classes.  If you use aspects, though, you can start with code
which has _no_ memory management, and write a single aspect which
describes reference counting, and have most of your memory management
problems solved.  (A second aspect might help with cycles, and yet another
aspect to handle some memory management staticly, since in some cases it's
easy.)

>It's an interesting idea, but something about code which
>can reach out and affect the behaviour of widely scattered
>parts of the program, in ways the authors of those parts
>didn't anticipate, makes me uneasy. Smacks of the legendary
>come-from statement, somehow...

You mean like overriding a method in a subclass?  (Exactly.)  Or since
gotos are harmful, we shouldn't use any loops, because they're implemented
using gotos.

I agree with your hesitation -- AOP isn't proven yet, and right now
AspectJ looks like a limited semantic-based preprocessor more than a
language (still a nice thing to have!).  However, none of the arguments
you cite stand on their own; you need to back them up, or some smartmouth
will come up with parallel arguments to known-useful technologies.

;-)

I'm pretty impressed with aspects, especially since they're so easy to
understand.  But I see a good case for holding off on depending on them.

>Greg

-- 
-William "Billy" Tanksley




More information about the Python-list mailing list