[aosd-discuss] "AOP considered harmful"

Dean Wampler dean at aspectprogramming.com
Wed Apr 27 19:57:22 EST 2005


I've given some thought to applying Meyer's "Design by Contract" (DbC) 
to aspects and how aspects need to respect the contract of the advised 
code.

The Liskov Substitution Principal applies; If a class is substitutable 
for an interface, then the class+advice must be, too. This means that if 
a method in the class stipulates precondition A (conditions that must be 
met on entry to the function) and satisfies postcondition B (guaranteed 
results, if the preconditions are satisfied) and invariant C, then 
before advice needs to be contravariant with respect to A, convariant 
with respect to B, and invariant with respect to C.

"Contravariant with respect to A" means that the advice must stipulate a 
contract equivalent to A or /weaker/ than A; if it stipulated a contract 
/stronger/ than A, then it won't be substitutable for the class. A 
weaker contract is okay.

"Convariant with respect to B" means that it must guarantee to meet the 
postconditions B or /stronger/ conditions (again, to satisfy 
substitutability, it can't relax the "promise").

Finally, any invariants must be respected.

I've been working on a paper, which needs a lot of work, that discusses 
DbC in more detail (along with other design principles):

http://www.aspectprogramming.com/papers/AOPerspectiveOnOOD.pdf

dean


Ron Bodkin wrote:
> [snip]
> 
> Re: the Liskov Substitution Principal and adherence to contracts, I think
> most real systems have best efforts informal documentation of semantics,
> which is far less than a contract. So what does it really mean that you can
> substitute one subtype for another? How do you know what pre-conditions and
> post-conditions apply? 
> 
> [snip]
> 
> -----Original Message-----
> From: Juri Memmert [mailto:memmert at jpmdesign.de] 
> Sent: Tuesday, April 26, 2005 10:20 PM
> To: Bill Burke
> Cc: AOSD; Ron Bodkin
> Subject: Re: [aosd-discuss] "AOP considered harmful"
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Bill Burke wrote:
> 
> [snip]
> 
>>>I question this in practice in large OO systems. Without tools 
>>>support, finding the possible subclasses or implementers of something 
>>>is quite difficult, so knowing what actual implementation code will 
>>>execute is hard.
> 
> 
> Yes and no. Unless you messed up your implementation, the Liskov
> Substitution Principle still has to apply. And so you have a general notion
> of the contracts the application will abide by. If you did break that
> principle, you've already doomed your application to die a slow and
> agonizing death.
> 
> [snip]  ...

-- 
Dean Wampler, Ph.D.
dean at aspectprogramming.com
http://www.aspectprogramming.com
http://www.contract4j.org
I want my tombstone to say:
    Unknown Application Error in Dean Wampler.exe.
    Application Terminated.
    [Okay]    [Cancel]



More information about the discuss mailing list