Re: Clean Object Class Design -- Circle/Ellipse
From: Dave Harris <brangdon_at_cix.co.uk>
Date: Mon, 8 Oct 2001 21:28 +0100 (BST)
Message-ID: <memo.20011008212857.61375A_at_brangdon.madasafish.com>
Date: Mon, 8 Oct 2001 21:28 +0100 (BST)
Message-ID: <memo.20011008212857.61375A_at_brangdon.madasafish.com>
bbadour_at_golden.net (Bob Badour) wrote (abridged):
> How does Smalltalk:
> * allow me to declare circle as a subtype of ellipse?
> * allow me to send the setFoci message to ellipse variables (that
> incidentally contain circle values) with two different focal points?
> * prevent me from sending the setFoci message to circle variables?
If we need Circle to be a subclass of Ellipse, we probably need to make them immutable. So instead of setFoci we would have withFoci. Like:
Circle>>withFocii: aPoint and: anotherPoint
^aPoint = anotherPoint ifTrue: [Circle newCenter: aPoint radius: self radius] ifFalse: [Ellipse newFocii: aPoint and: anotherPoint radius: self radius]
Dave Harris, Nottingham, UK | "Weave a circle round him thrice,
brangdon_at_cix.co.uk | And close your eyes with holy dread, | For he on honey dew hath fedhttp://www.bhresearch.co.uk/ | And drunk the milk of Paradise." Received on Mon Oct 08 2001 - 22:28:06 CEST