Complex as extension of Point ... Aaaaargh!

stéphane ducasse ducasse at iam.unibe.ch
Sat Oct 8 18:42:42 UTC 2005


I would say because subtyping in always better than subclassing for  
substituability point of view and client understanding your code.
So if you have behavior in point that does not work for complex, then  
do not subclass from Point.
Cancelling behavior is a smell that you are overusing inheritance.

Stef

On 8 oct. 05, at 12:40, Stéphane Rollandin wrote:

> John H Woods wrote:
>
>>> I had also wondered about building Complex out of Point.
>>>
>> IMHO: PLEASE don't do this.
>>
>
> you give good and convincing reasons not to do so.
>
> but, just for the record:
>
>
>>  I feel
>> that the only reason Complex looks like a child of Point is that  
>> it has two
>> components --- but then, so does Association!
>>
>
> not quite. a complex number can be seen as a point. mathematically  
> there is no difference in nature, as we know since 1806:
>
> http://en.wikipedia.org/wiki/Jean-Robert_Argand
> http://en.wikipedia.org/wiki/Argand_diagram
>
>
>
>>  true to its
>> graphical origins, Point interprets '*' to mean scaling
>>
>
> yes, this is really why having Complex be a Point is not convenient.
>
>
> regards,
>
> Stef
>
>




More information about the Squeak-dev mailing list