Re: SubTyping versus SubClassing
From: Dmitry A. Kazakov (mailbox_at_dmitry-kazakov.de)
Date: 09/16/04
- Next message: groups: "Re: dip Notions 2 Major Errors"
- Previous message: cmedcoff_at_hotmail.com: "Security in the Domain Model"
- In reply to: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Next in thread: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Reply: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Reply: Mark Nicholls: "Re: SubTyping versus SubClassing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 16 Sep 2004 11:19:17 +0200
On 15 Sep 2004 19:10:57 -0700, Alfredo Novoa wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message news:<tur21vlxh26i$.1o30kblqzehkq.dlg@40tude.net>...
>
>> [to answer this question you have to define "value".
>
> An element of a set.
Any element of any set? Values used in programs represent an immeasurably
small subset of ones used in mathematics.
>> It is not easy to do
>> as it might appear, especially without the notion of an abstract type.
>
> It is easy because a value is simply an element of a set.
Then you have to have sets before values. OK, what is a set of values? Your
statement above defines neither set nor value.
>> Welcome to a vicious circle! Of course you can claim that value = memory
>> bit pattern, but clearly it would lead to nowhere.
>
> I disagree, "value" is mathematical concept and it can't be defined as
> a memory bit pattern.
You cannot use mathematical values as-is, to describe types appearing in
programming. You have to limit them. This is equivalent to define the term
"value".
>> Once you fix the definition, you will probably discover that your notion of
>> subtype is quite wrong.
>
> How can I fix the definition?
>
> My definition is the standard definition.
>
> http://www.nist.gov/dads/HTML/abstractDataType.html
It reads "A set of data values and associated operations that are precisely
specified independent of any particular implementation". Note
implementation independence. This implies my these: we have to talk about
mappings rather than about singular objects. This is also the standard way
used in mathematics. When for example, real numbers (R) are constructed
using say, Dedekind's sections, nobody cares that technically R is not a
superset of N (natural numbers). Implementation is no matter, there is a
mapping N->R, which is all we need.
>> One should talk not about [sub]sets of values, but
>> about [surjective] mappings of values.]
>
> How do you define "mapping".
A function, a set of ordered pairs.
> But you are using the word "value" again.
Yes, but I do not need to study them. When you say that A is a subset of B,
then you are bound to "any member of A is a member of B". You have that
nasty "is a". How to check if x "is" y? By memory address? By memory
content? By calling operator "="? See, we are sinking in implementation
details. With mappings we only claim that we know a way to find for some x
of A some y in B. We won't tell which way, of course! (:-))
>> Rational numbers are
>> ones having a representation as Q/R, where both Q and R are integers.
>
> Rational numbers are ones that can be expressed as a fraction where p
> and q are integers and q <> 0.
>
> Rational numbers with q = 1 are also integer numbers.
>
> BTW rational numbers are a subset of real numbers.
See above.
>>> or Square is a subtype of Rectangle.
>>
>> It depends. If you mean in-methods of Rectangle, then yes to have for any
>> Square a rectangular counterpart is useful. But consider out-methods, for
>> which you'd better have a square for each rectangle, which is impossible.
>
> No, you have a rectangle for each square. If you have 10 squares you
> have at least 10 rectangles.
But it is not what I need for out-methods. Namely, to prove theorems with
the quantor "exists".
For example: for all height, all width exists rectangle of that height and
width. Substitute square there and it will be wrong. So this theorem does
not hold though each geometric square is a rectangle.
It shows that to have the domain a subset is just too weak for our needs,
if we would define subtypes in this way. The reason is that you forgot
about *operations*. Anyway, what for are values if I can do nothing with
them? Operations defined on the types are that theorems we have to prove
when we claim that A is a subtype of B. I.e. a subtype A *inherits*
operations of B. Note what happens with values is an implementation detail!
This is much stronger and useful than just to say that A inherits values of
B. LSP requires *all* theorems to be true, which is another pole to yours.
It is too strong to conform, alas. The truth lies, as always, in between.
-- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
- Next message: groups: "Re: dip Notions 2 Major Errors"
- Previous message: cmedcoff_at_hotmail.com: "Security in the Domain Model"
- In reply to: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Next in thread: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Reply: Alfredo Novoa: "Re: SubTyping versus SubClassing"
- Reply: Mark Nicholls: "Re: SubTyping versus SubClassing"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|