Re: Clean Object Class Design -- Circle/Ellipse

From: Bob Badour <bbadour_at_golden.net>
Date: Sun, 5 Aug 2001 13:54:35 -0400
Message-ID: <eTfb7.272$Hz3.22450293_at_radon.golden.net>


>>>Are the integers a subtype of the reals? It depends on which axioms you
>>>are considering. If you are looking at them as a plain set, monoid or
>>>group, the answer is yes. If you are looking at them as a field or a
>>>real vector space, the answer is no.
>>
>>Doesn't this amount to: If one starts with the axiom that integers are a
>>sub-type of real, they are, and if one starts with the axiom that
>>integers are not a sub-type of real, they are not.
>>
>>If so, I question the utility of the observation.
>
>No no, that's not it. That would indeed be pointless. Let me give some
>details.
>
>Commutative groups are a well known kind of mathematical structure defined
>by a handful of axioms:
>
>A nonempty set G combined with a binary operation + is called a commutative
>group if the following axioms hold:
>
>associativity: (a+b)+c=a+(b+c) for all a,b,c in G
>neutral element: there exists an element (denoted 0) such that a+0=0+a=0
>for all a in G
>inverse: for every element a there exists an element b such that a+b=0
>commutativity: a+b=b+a for all a,b in G
>
>Clearly, if we take G=the real numbers and +=ordinary addition then the
>above axioms hold. If we take the subset of all integers, we see that the
>axioms hold as well. The integers are a subgroup of the reals.
>
>Another well known structure is a field. It satisfies all the axioms of a
>group plus the following ones concerning a second binary operation *:
>
>associativity: a*(b*c)=(a*b)*c for all a,b,c
>neutral element: there exists an element 1<>0 such that 1*a=a*1=a for all a
>inverse: for all a<>0 there exists an element b such that a*b=b*a=1
>commutativity: a*b=b*a for all a,b
>
>For G=the reals the axioms are again satisfied, the reals are a field. But
>this does not apply to the integers, even though they are closed under +
>and *. What goes wrong is that not every nonzero integer has an integer
>multiplicative inverse.

However, if one models the domain of Integer as a sub-type of Real, what goes right is that every nonzero Integer has a Real multiplicative inverse. The inherited operation as defined for the super-type, Real, holds equal validity for Integers.

If one defines an additional multiplicative operation on two integers, that is an operation on the sub-type and not one the super-type; hence, not inherited. Such occurs frequently in inheritance relationships. For instance, a circle has a radius while an ellipse does not.

>>The person who determines the types available to the DBMS will
>>necessarily determine the axioms. In providing support for user-defined
>>types, the DBMS, itself, should not impose any unecessary axioms on the
>>type system.
>
>If an algorithm doesn't depend on every nonzero element having an inverse,
>than you're fine with integers as a subtype of real.

You are overlooking the fact that the Integer does have a Real inverse. Since the algorithm is defined in the base class, it will continue to work just fine.

>>>The present discussions has not specified the context. Without the
>>>context the question "are the integers a subtype of the reals" is
>>>ill-posed.
>>
>>However, that is not the question. The real question is: Is an
>>inheritance model that prohibits a model of integer as a sub-type of
>>real a valid model of inheritance?
>
>What makes something a "valid" model of inheritance? We'd have to be more
>precise about what we mean by inheritance.

Read what others have to say about the Circle-Ellipse inheritance issue and you will see that they are really just stating that the inheritance does not work well in the language they use.

>>I fail to see how Date's model of inheritance prevents any type designer
>>from modelling integers as if they are not sub-types of real.
>>
>>
>>Show me the proof that Date's article documents a lack of understanding
>>of types and OO. Show me the proof that the utility of Date's
>>inheritance model approaches zero. Both are extraordinary, incorrect
>>(and apparently axiomatic) claims.
>
>Don't get me wrong, I didn't say Date doesn't understand types or OO.

Yes, that is exactly what you stated! ...

>All I said was that the statement was not
>extraordinary, it was just too vague.

...and the statement was truly extraordinary. You have only demonstrated that you do not understand inheritance and type. Received on Sun Aug 05 2001 - 19:54:35 CEST

Original text of this message