Re: Clean Object Class Design -- Circle/Ellipse
Date: Mon, 13 Aug 2001 17:16:01 -0400
Message-ID: <3B784391.6E8F5DB9_at_alum.mit.edu.->
Re
peter_douglass wrote:
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.
Tak To wrote:
TT> But some of properties of an operation pertain to the set of TT> values itself rather than individual values (e.g., closure TT> rules). Hence the difference. PD> I don't see how closure rules affect substitutability. The result PD> of adding two integers is again an integer. The result of adding PD> two values from the set {0,1} might lie outside that set, but it PD> is still an integer. I don't see how code that is written toPD> handle integer _values_ could fail if it were passed bit _values_. PD> (I stress the word _values_).
My point is: ordinary addition is not closed for the set {0,1} (let's call this set Int2) but is closed for Integer.
I.e., programs code that is written for _All_Integers_ (which is a set) values could be broken when fed a _All_Int2_ value[*]. For example, consider a function f(a,b,S) which checks if the sum of a and b is a member of S:
f( any Integer, any Integer, _All_Integer_ ) is always true, but f( (Int2)1, (Int2)1, _All_Int2_ ) is not.
It is not an issue of values vs variables, but axioms on individual elements vs axioms on the domain set itself.
[*] The fact that _Set_of_all_Integers_ is infinite is immaterial. If you prefer, we can switch to the venue of 32 bit integers (and 32-bit modulus addition) instead.
Since Date never consider the domain set itself as value, this is not an issue for him. However, in software engineering domain as value is a common occurrence (e.g., consider the fact that "constructors" are really functions with the domain set itself as an implicit argument) and that is why I said that the LSP notion is more "useful".
Tak
-----------------------------------------------------------+---------- Tak To takto_at_alum.mit.edu.- --------------------------------------------------------------------^^ [taode takto ~{LU5B~}] NB: trim the .- to get my real email addrReceived on Mon Aug 13 2001 - 23:16:01 CEST