Re: Clean Object Class Design -- Circle/Ellipse
Date: Sat, 21 Jul 2001 19:54:52 GMT
Message-ID: <f6l67.2284$ar1.6417_at_www.newsranger.com>
In article <Gzj67.2209$ar1.6291_at_www.newsranger.com>, Mikito Harakiri says...
>
>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.
That sounds like paradoxical conclusion, at first, but little analysis shows that the statement "Reals is a subtype of Integers" withstands LSP test. If we have currency calcualtor working with integers, we can substitute integers with rationals or even reals (if such thing exists in computers;-), and all the operations would still meet the old semantics.
>BTW, you could collapse your example further down to groups: then we come to
>octic group interpretation in square/rectangle case.
At the end of "LSP: square/rectangle again" thread Mikito noticed that applying algebra operations to an Rectangle element seemingly produces less elements than we have in Square class. It is essentially the same as to say that there are less integers than reals. Which is an obvious problem as we don't want to interpret subtyping in any way inconsistent with Set Theory. If we have a model (for example, <I, {+,*}>) defined as a set I with a signature {+,*}, then sybtyping a model shouldn't be inconsistent with subset operation on the model sets I and R (aka universes).
My reply to Mikito message in "LSP: square/rectangle again" thread could be translated into Integer/Real case as follows: Just change the set in the integer model to reals. Extend operations to fractional numbers as follows:
When calculating ariphmetic operations, just move the identical fractional parts
into the operation result. For example:
1.5+2.5=3.5 (and not 4.0!)
However,
3.1+2.5 = undefined
Therefore, we've got an integer algebra on the universe of reals! Integer algebra defined that way is a true supertype of Reals (both have the same universe).
In short, producing equivalent classes R/[0,1) as a universe of IA algebra of integers confuses the matter... Received on Sat Jul 21 2001 - 21:54:52 CEST
