Re: Clean Object Class Design -- Circle/Ellipse

From: Marc Gluch <marc.gluch_at_mindtap.com>
Date: Sat, 18 Aug 2001 20:41:23 GMT
Message-ID: <3b7ec61f.3677021587_at_news.grpvine1.tx.home.com>


On Sat, 18 Aug 2001 11:57:25 -0400, "Bob Badour" <bbadour_at_golden.net> wrote:

>>The only "fool-proof" way of deciding if A is a subtype of B,
>>that I know, is to treat A and B as formal theories.
>>
>>The first questions to consider would be:
>>Are A and B consistent?
>>Does one make more assumptions (postulate more axioms) than the other?
>
>
>Are you arguing that every subtype must postulate more axioms than its
>supertype does?

Yes.
Note that you can't produce the axiomatization of Integers by extending the axiomatization of Reals (or Rationals). You actually would have to drop some axioms. Thus my assertion that Integer is not a subtype of Real, even though the set of Integers is a subset of the set of Rationals is a subset of Reals.

> If so, I tend to agree. If not, can you think of any subtype that does not?
Again yes, depending on the definition.
In another post I considered several possible definitions, one being the reverse of the one given above. Under such definition subtyping becomes generalization, with the consequence that you can make Rationals or Reals be subtypes of Integer. You even get such nice properties as code inheritance, but clearly this is not a definition that one would expect. I eliliminated this definition (generalization) from further considerations on the basis that the intensional definition of subtype must be consistent with (but not necessarily equal to) the extensional definition of subset.

>>Finally the utility question; can elements of A be substituted for
>>elements of B without breaking the theory of B?
>Are you arguing that one cannot substitute integer values for real values.
>Does this mean that one cannot evaluate (2 * pi) because 2 is an integer
>value? If so, how do we relate a circle's radius to its circumference?
Sort of. To be exact, I'm arguing that one can't substitute integer function for real/rational function (but after all, given a set of values as parameters, any function is just a non-cannonical representation of some value, and in particular any function of integers, defined in terms of + and *, should produce an integer, so that this function has a closure within a set of the values that it takes parameters from). But no matter how you define integer inverse(integer), that definition will be inconsistent with the definition of rational inverse(rational).

>>Also, note that there is no single right way (whether it's Date's way
>>or not) ) to model the "real world".
>>Both set theory and lambda calculus can be used as foundations for
>>mathematics, but each approach will make different things easier
>>(or harder) to prove.
>
>While I do not want to speak for anyone else, I think you will find that
>many people consider both set theory and lambda calculus simply part of the
>real world -- just as the value 1 is part of the real world.
You missed my point. Date claims that math is the arbiter of what is " the right way" to model the world. I counter by observing that math itself has many ways to model the same thing, so no single way is the right way. It's always *right with respect to ...*. IOW, what's right depends on your objectives.

Definition subtype = subset may be (and probably is) right in the db world. It is not so in the programming world.

Perhaps you can help me see the benefits that Date brings to the programming table. So far al I can see is that his definition prevents me from using any machinery that the programming language theory developed over the years (I can't derive a COLORED_CIRCLE from CIRCLE, but I must derive Integer from Real). Pretty bizzare.

Marc Gluch
Mindtap Inc. Received on Sat Aug 18 2001 - 22:41:23 CEST

Original text of this message