Re: Clean Object Class Design -- Circle/Ellipse

From: peter_douglass <baisly_at_gis.net>
Date: 11 Aug 2001 08:10:43 -0700
Message-ID: <feff00b6.0108110710.254aceff_at_posting.google.com>


Tak To wrote:

[snip]

> PD> All common properties which are shared by every value
> PD> of a type must be shared by every value of the subtype. This
> PD> includes operations.
 

> But some of properties of an operation pertain to the set of
> values itself rather than individual values (e.g., closure
> rules). Hence the difference.

I don't see how closure rules affect substitutability. The result of adding two integers is again an integer. The result of adding two values from the set {0,1} might lie outside that set, but it is still an integer. I don't see how code that is written to handle integer _values_ could fail if it were passed bit _values_. (I stress the word _values_).  

> Incidentally, in which of Date's books does he talk about this?

The book version of The Third Manifesto has a lengthy section on subtyping.  

> TT> I think Date says it quite clearly that operations are not
> TT> automatically inherited.
 

> PD> Not per-se, but there must be a way to implicitly cast from a
> PD> representation of a subtype to a representation of a type. If
> PD> you put a circle in a column whose domain is ellipses, then
> PD> the you may ask the circle for it's foci, eccentricity, etc,
> PD> just as you could if you had put in an ellipse representation
> PD> that happened to be a representation of a circular ellipse.
 

> Well, I was not referring to representation issues. I
> was referring to preserving the meaning (and validity) of
> operations independently of representation.

Well, in that case, I would like to revise my comment in agreement with your statement that per Date, operations are not automatically inherited. If we abstract away the representation of a value, then operations are automatically inherited. Thus, if we might define a type circle, which lacks some operations normally associated with ellipses. However, if we define an ellipse type and declare circle to be a subtype, then if a circle value is used in a context where an ellipse is expected, then the circle (value) will support all of the operations of an ellipse (value).

--PeterD Received on Sat Aug 11 2001 - 17:10:43 CEST

Original text of this message