AOP use cases

Peter Hansen peter at engcorp.com
Sat Apr 24 13:36:35 EDT 2004


Tor Iver Wilhelmsen wrote:

> Peter Hansen <peter at engcorp.com> writes:
> 
>>I would be very interested to hear some real-world and real useful
>>use cases for AOP as well.  So far, the logging example seems to
>>be put forth so often that I'm starting to suspect that's the
>>*only* "useful" thing people are doing with it. :-)
> 
> A couple of other examples:
> 
> - Implementing Singleton as an aspect which states that calling
>   set*(self, value) methods on a set of classes should raise an
>   AttributeError - or just do nothing
> - Measure execution time of a method by wrapping an aspect-"advice"
>   around it

Hmm.... maybe I need to clarify what I mean by "real-world".

To mean, the term means something like "drawn from actual, working
code in real projects implemented to achieve useful, practical
results", as opposed to what, so far, pretty much everyone who
proposes examples seems to think, which is more like "potentially
interesting theoretical ideas which sound kinda cool"...

Has anyone used AOP in a real project, which wasn't a project just
to demonstrate AOP?  For anything other than the logging example?
If so, what was the specific value provided by AOP, and can you
post a snippet or two of code which demonstrates the cleaner structure
provided by the clear separation of concerns which you believe comes
from AOP practices?  And thank you. :-)

(And I'll reject at this point examples which are no different than
how any number of us use Python to wrap existing methods in
useful ways, such as the synchronization scheme presented earlier
in this thread.  Why?  Because if that's the best you can do, then
I don't think AOP deserves to be recognized in the Python world as
anything other than a fancy buzzword for something which we should
all be doing already as we ensure our code is decoupled and has little
duplication.  That probably means your example will come from the
Java world, or elsewhere, but I wouldn't reject it out of hand just
because it's in Python.)

-Peter



More information about the Python-list mailing list