Re: Clean Object Class Design -- Circle/Ellipse

From: Marc Gluch <marc.gluch_at_mindtap.com>
Date: Sat, 21 Jul 2001 20:32:30 GMT
Message-ID: <3b59dedd.1561713695_at_news.grpvine1.tx.home.com>


On Sat, 21 Jul 2001 18:09:42 GMT, Mikito Harakiri <nospam_at_newsranger.com> wrote:

>In article <3B592B47.40E4C48B_at_mindtap.com>, Marc Gluch says...
>>
>>Let I be the set of integers and R of reals. I is a subset of R
>>(we are talking abstract types, not machine implementations - Date's data
>>independence).
>>Now consider algebras IA = <I, {+,*}> and RA = <R, {+,*}>,
>>with the standard interpretation (specification) of summation and multiplication.
>>Is IA a subtype of RA? Chris Date would have you believe so.
>>But RA is a field, whereas IA is only a ring (and thus does nort preserve all
>>properties of RA).
>>In conclusion, we can't substitute integerobjects for realobjects in all programs
>>written using realobjects,
>>and if we try, some of these programs will break (namely these that rely on x * 1/x
>>= 1).
>>
>
>No, RA is a subtype of IA, even though I as a universe of IA is a subset of R as
>a universe of RA. It is a set of operations that we want to subset, not the
>universe.
My original point was to show Date's mistake of confusing sets and types.

Going back to the topic of clean design, looking at RA as a subtype of IA
gives us little/no milage in designing class hierarchy.

IOW, just because RA is a subtype of IA doesn't mean that we have to (or want to) subclass Real (implementation of RA) from Integer (implementation of IA).

OTOH, subclassing both Integer and Real from Number helps to keep the design clean.

Marc Gluch
Mindtap Inc. Received on Sat Jul 21 2001 - 22:32:30 CEST

Original text of this message