Re: Another OO Problem (and thanks for the input I received so far)
From: Programmer Dude (Chris_at_Sonnack.com)
Date: 11/03/04
- Next message: Randy Howard: "Re: Choosing between C and VB"
- Previous message: Programmer Dude: "Re: scripting languages vs statically compiled ones"
- Maybe in reply to: Programmer Dude: "Re: Another OO Problem (and thanks for the input I received so far)"
- Next in thread: Michael Mendelsohn: "Re: Another OO Problem (and thanks for the input I received so far)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 02 Nov 2004 17:51:18 -0600
TGOS writes:
> An ellipse needs RadiusA and RadiusB. But a circle has only one radius.
> So it would over two getRadius that always yield the same result; so
> there is one too much. This may however be desired, if you want to use a
> cirle as a special kind of ellipse.
>
> On the other hand, a circle could offer getRadius and an ellipse could
> extend it with getAlternateRadius or getSecondRadius.
>
> Both is probably possible...
Indeed. If I did decide that a circle should be a sub-class of ellipse,
I'd inherit and hide the second focal point and radius and add a class
invariant insuring those fields were always the same value.
There are also issues going the second direction. If a circle has a
centerpoint field and a radius field and you inherit circle to ellipse,
which focalpoint inherits circle's centerpoint, and which radius gets
circle's radius?
I might very well do what some paint programs have done and consider
them as distinct classes that both inherit from shape. That is, neither
inherits from the other. For most programming purposes I can think of,
circles and ellipses just aren't that related.
- Next message: Randy Howard: "Re: Choosing between C and VB"
- Previous message: Programmer Dude: "Re: scripting languages vs statically compiled ones"
- Maybe in reply to: Programmer Dude: "Re: Another OO Problem (and thanks for the input I received so far)"
- Next in thread: Michael Mendelsohn: "Re: Another OO Problem (and thanks for the input I received so far)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|