Re: Clean Object Class Design -- Circle/Ellipse
Date: Sun, 19 Aug 2001 20:12:42 GMT
Message-ID: <3b801b09.3758364652_at_news.grpvine1.tx.home.com>
On Sun, 19 Aug 2001 16:40:03 GMT, "Richard MacDonald" <macdonaldrj_at_att.net> wrote:
>
Marc Gluch
>> > An axiom limited to functions where the
>> >argument and result are the same type
>> >isn't any good for building a type theory.
>>
>> Actually, it is. It guarantees LSP.
>
>In a uselessly limited version? If I can't ask a Person for his/her age,
>what's the point? Or are you also trying to derive this extension from
>the axioms?
Did you read the paragraph following this statement? Age does not
produce values of the supertype (IOW it is not a polymorphic operation
between Person and some sublcass of Person). You can inherit it,
unless the sublass requires a different (inconsistent) interpretation.
>> To begin with, I only ask that set set of axioms of the supertype
>> be a subset of the set of axioms of the subtype (wrt the standard,
>> FOL disjunctive normal form representation of these axioms),
>> and only for abstract types. That result is the same type
>> as arguments is just a consequence of that requirement
>> (for operations that produce values of the supertype)
>> in combination with the closure axiom.
>>
>> Note: I also ask that the two axiomatizations are consistent,
>> meaning not every constraint is an axiom.
>>
>> Once you are down to concrete classes, they are not subtypes
>> but rather implementations of the abstract type.
>> They are not (directly) substitutable for one another --
>> the abstract supertype defines the conversion axioms.
>>
>> Another (side) point:
>> Given choice (knowledge, time, and materials), one should
>> use composition rather than inheritance (for example
>> construct rationals from itegers, not the other way around).
>
>That would be nice. The Smalltalk Fraction class does this.
>Integer and Fraction are still subclasses of Number, though.
>And you're still going to have to define some of your Integer
>operations to answer Rational/Fraction. How are you going to
>do this? (Pardon my density :-)
Not in the Integer class, but in Number (where these signatures
belong) and in Rational or Real (where their implementations belong).
with Number dispatching the computation to appropriate subclass.
Mindtap Inc.
Received on Sun Aug 19 2001 - 22:12:42 CEST