Re: Mixing OO and DB

From: S Perryman <q_at_q.com>
Date: Wed, 20 Feb 2008 15:16:17 +0000
Message-ID: <fphg87$m3c$1_at_aioe.org>


Robert Martin wrote:

> On 2008-02-19 22:14:36 -0600, David BL <davidbl_at_iinet.net.au> said:
>> I think you are oversimplifying what substitution means.

>> What exactly do you mean by "program"?

> I was using Liskov's words.

>> It sounds like you refer to
>> the entire source code for an application, but that would include the
>> code that defines T and S.

> Let's restrict P to the set of code that directly uses, but does not
> define, T.

>> Moving on, you say that *every* program P that works with T should
>> also work with S.  Suppose S' is another subtype of T.   Let program P
>> be the following

>>     // declaration
>>     void foo(T* x);

>>     // call
>>     S' s;
>>     foo(&s);

>> We cannot replace T with S in this code, because the cast from S'* to
>> S* isn't valid. So presumably you mean something else by "works >> with". What exactly? Can you formalise that?

> 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.

> 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.

The apocrypthal Circle/Ellipse "problem" being a simple example of this.

Regards,
Steven Perryman Received on Wed Feb 20 2008 - 16:16:17 CET

Original text of this message