[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OO should break when broken




On Thursday, September 4, 2003, at 02:59  PM, Colin Putney wrote:

>
> On Thursday, September 4, 2003, at 10:59  AM, John Clements wrote:
>
>>> No. Obviously there isn't. Let me rephrase my claim: "For every 
>>> valid instance of LinkedList, there is at least one valid instance 
>>> of LinkedListWithFastSize." The same holds true for 
>>> LinkedListWithTimeStamp: "For every valid instance of LinkedList, 
>>> there is at least one valid instance of LinkedListWithTimeStamp." 
>>> Was your objection to my loose usage of 'valid LinkedList,' or to my 
>>> broader position on subclassing?
>>>
>>> The point is that the full range of state that is valid in the 
>>> superclass is also valid in the subclass. It isn't restricted, which 
>>> Vesa claimed was "the essence of a subclass."
>>
>> No, I disagree.  It _is_ restricted.  How is it restricted?  It is 
>> restricted because it _must_ contain the extra state.  So, for 
>> instance, the LinkedListWithTimeStamp restricts the LinkedList by 
>> requiring the presence of the TimeStamp state.  Likewise, the 
>> LinkedListWithFastSize restricts the LinkedList by requiring the 
>> presence of the cached size state.
>>
>> I think the key point is that the set of "LinkedLists" doesn't just 
>> include direct instances of LinkedList; it also includes instances of 
>> any possible subclass thereof.
>>
>> ***
>>
>> Here's my argument:
>>
>> 1. if B is a subclass of A, then A is the more general one.  Always.
>
> <sigh>
>
> This is getting ridiculous.
>
> I'm not interested in debating the meaning of the word restricts, or 
> the semantics of the set of all possible instances of a hypothetical 
> class. You're quibbling about minor details of my overall argument, 
> but completely ignoring my conclusion.
>
> Unless somebody wants to post code in an OO language showing an 
> implementation of Circle as a useful subclass of Ellipse, this is my 
> last post in this thread.

Ellipse.java:
class Ellipse extends Object {
     float long_axis;
     float short_axis;

     public Ellipse(float long_axis_init, float short_axis_init)
     {
	long_axis = long_axis_init;
	short_axis = short_axis_init;
     }
}

Circle.java:
class Circle extends Ellipse {

     public Circle(float radius)
     {
         super(radius, radius);
     }
}



Yours,

john clements