LSP Was: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Thu, 21 Feb 2008 12:16:49 -0600
Message-ID: <2008022112164944303-unclebob_at_objectmentorcom>


On 2008-02-20 09:16:17 -0600, S Perryman <q_at_q.com> said:

>

>> S is any and every subtype of T.  S' is in the class of S.
>> Remember, Liskov's rule was an attempt to define what S was. In essense 
>> she said that subtypes are those things that are substitutable.

>
> No.
> Liskov and Wing define their subtype predicate in a specific way, using a
> substitutability predicate. The latter predicate they also define very
> precisely.

Maybe I'm missing something. The principle has been around for a long time. The old quote from the May, 1988 Sigplan Notices was:

"What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P deÞned in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T."

Are you referring to something else?

>> What this means, of course, is that some S may be a subtype of T for 
>> one particulr P but not for another.  Liskov's rule implies that being 
>> a subtype is not intrinsic, it is an attribute evaluated by the user.  
>> It is P that shows that S is a true subtype of T.  S and T cannot prove 
>> their relationship without P.

>
> Not true.
> The Liskov/Wing definition of substitutability and subtype is
> mathematically definable. Therefore for any given T1, T2, it may be
> possible to prove the relationship (subtype or not +/- when) without regard
> to P.

Given the quote above, I'm not sure how you can come to that conclusion. Even if you use the more recent 1999 quote:

"Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T."

We still wind up with subtyping being defined based on q, where q is *a property*, not all properties, which means that S is only a subtype for those programs that use the q properties. Any program that uses properties of S that don't meet the criteria do not view S as a subtype.

-- 
Robert C. Martin (Uncle Bob)ÊÊ| email: unclebob_at_objectmentor.com
Object Mentor Inc.Ê Ê Ê Ê Ê ÊÊ| blog:ÊÊwww.butunclebob.com
The Agile Transition ExpertsÊÊ| web:ÊÊÊwww.objectmentor.com
800-338-6716Ê Ê Ê Ê Ê Ê Ê Ê ÊÊ|
Received on Thu Feb 21 2008 - 19:16:49 CET

Original text of this message