Re: Clean Object Class Design -- Circle/Ellipse

From: Bob Badour <bbadour_at_golden.net>
Date: 10 Oct 2001 18:44:18 -0700
Message-ID: <cd3b3cf.0110101744.782296d_at_posting.google.com>


"James A. Robertson" <jarober_at_mail.com> wrote in message news:<3BC199E9.8020103_at_mail.com>...
> Use one I'm actually likely to stumble on in a real application I might
> write.
>
> Bob Badour wrote:
>
> > Using the real example of circle and ellipse:
> >
> > How does Smalltalk:
> > * allow me to declare circle as a subtype of ellipse?
>
>
> I subclass Circle from Ellipse
>
>
> > * allow me to send the setFoci message to ellipse variables (that
> > incidentally contain circle values) with two different focal points?
>
>
> I override the methods in the subclass so that each gets appropriate
> behavior. If the ellipse variable contain circle values, ,my
> application code is wrong>

Are you saying that Smalltalk does not allow polymorphism?

> > * prevent me from sending the setFoci message to circle variables?
>
> See above.

Overriding setFoci does not prevent me from sending the message, does it?

> If I find that I'm overriding enough methods, subclassing was a bad
> choice. You have created an example 'problem' that isn't much of a
> problem.

If Smalltalk made sufficient distinction between values and variables, one would not need to override setFoci in the Circle class because it would never inherit the method. Circle values would inherit the operations on Ellipse values but Circle variables would not inherit the operations on Ellipse variables. Received on Thu Oct 11 2001 - 03:44:18 CEST

Original text of this message