AOP use cases

Peter Hansen peter at engcorp.com
Sat Apr 17 10:47:25 EDT 2004


Joe Mason wrote:

> In article <AZ-dnUNqC9-oUh3dRVn-jw at powergate.ca>, Peter Hansen wrote:
>>Sorry, but that doesn't fly.  That's a clearly separate function
>>that should have a simple, single call somewhere in the application.
> 
> Not at all.  You'll want to log when calls start and end, when features
> are turned on and off, when specific services (voice mail, call
> forwarding) are accessed.  If your app is for a call center, you want to
> log when people go on and off hold and when they enter specific service
> queues.  

Okay, even given that we're talking about something hypothetical
(I'm _quite_ interested in evidence that AOP for such things is
more than just someone's cool theory), why wouldn't I just do this
as a series of calls in the appropriate places?  If I'm going to
specify which methods of which classes/objects are getting this
"logging" functionality, it seems to me that I can do that as
easily (i.e. one line of code) by just making it explicit in
the code that does the call.

And if I had to do this in such a variety of "arbitrary" places
that it would appear to be a maintenance issue or something, I
would turn to data-driven programming and just have the appropriate
logging calls inserted using wrappers around the methods of
interest as the application configures itself.

So where does AOP fit in?  I realize I'm basically asking the
same question some others have, as in what good does AOP provide
if it's so easy to do this using traditional techniques.  Or is
anyone arguing that what I'm actually doing is AOP even though
I don't call it that?  (In which case AOP should be relegated to
being a simple Software Pattern I guess.)

I think one problem I have with the logging example, even
modified from the contrived "log calls to all methods" case,
is that I've done such things, without the slightest feeling that
what I was doing was complicated or awkward or needed "a better way".
So what does AOP buy for such things?

(But I'm _really_ much more interested in real-world examples,
since we can discuss the theory of AOP all you like and still
not convince me or anyone that it's worth any change in our
way of doing things.  What's a *compelling* example?)

-Peter



More information about the Python-list mailing list