Opinions on Ellipse-Circle dilemma?
Author Message
Opinions on Ellipse-Circle dilemma?

Hello everybody!

I just read in Rumbaugh et al. that some people were very bothered
with it. Who are they?I think it is serious problem of OO as we now it.
I will like to hear your opinion, really.

_______________________________________________
Author: Kazimir Majorinc, Zagreb, Croatia

http:   //public.srce.hr/~kmajor (~7min to USA)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One who knows the secret of the 7th stair

Fri, 23 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

> I'm interested in your opinion about Ellipse Circle dilemma in C++.
> I just read in Rumbaugh et al. that some people were very bothered
> with it. Who are they?I think it is serious problem of OO as we now it.
> I will like to hear your opinion, really.

Oh no, not this thread again...  See the FAQ at
this topic.

IMHO there is no "dilemma" -- just try to describe a circle in terms of
an ellipse.  You'll hear things like "an ellipse with no excentricity"
or "ellipse with equal height and width" or "ellipse but just ..."

Now, all this "its an ellipse plus, or restricted to, etc." should be a
big red flag.  A circle is a special case, a somehow limited or
constrained ellipse.  If you can't just say a cicle is-a ellipse, and
have to qualify it, then its a specail case.

Well gosh, that pretty much blows away substitutability.  Meaning if you
derived circle from ellipse you couldn't necessarily use a circle
anywhere you were using an ellipse before.  After all, what if your use
of an ellipse violated the special conditions/restrictions placed on it
by circle?

The loud cry of "But a cicle has to be an ellipse, it just fits so
neatly into my conceptual picture of..." comes from people who aren't
going to use an ellipse as an ellipse and therefore aren't hindered by
the restrictions placed on a cicle-masquarading-as-an-ellipse.

--
Phil Staite               If I were an IBM spokesperson I'd have

Fri, 23 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

> Hello everybody!

> I'm interested in your opinion about Ellipse Circle dilemma in C++.
> I just read in Rumbaugh et al. that some people were very bothered
> with it. Who are they?I think it is serious problem of OO as we now it.
> I will like to hear your opinion, really.

of www.oma.com, and read principle #2: The Liskov Substitution Principle.

--
Robert C. Martin    | Design Consulting   | Training courses offered:

14619 N Somerset Cr | Tel: (847) 918-1004 |   C++
Green Oaks IL 60048 | Fax: (847) 918-1023 | http://www.oma.com

"One of the great commandments of science is:
'Mistrust arguments from authority.'" -- Carl Sagan

Sat, 24 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:
> IMHO there is no "dilemma" -- just try to describe a circle in terms of
> an ellipse.  You'll hear things like "an ellipse with no excentricity"
> or "ellipse with equal height and width" or "ellipse but just ..."

> Now, all this "its an ellipse plus, or restricted to, etc." should be a
> big red flag.  A circle is a special case, a somehow limited or
> constrained ellipse.  If you can't just say a cicle is-a ellipse, and
> have to qualify it, then its a specail case.

No, not necessarily.  You should not be creating subclasses just because an
attribute has a specific value.  You create subclasses when the interface
or attributes of the object are different.  Does a circle have the same
instance variables as a circle?  Yes.  Does a circle have the same
Interface?  Yes.  Does a circle have the same behavior for each interface?
No, but that doesn't mean that a circle and an ellipse are unrelated,
that's what why we have polymorphism.

A circle is an ellipse, ask any mathematician, the real question is can a
circle be modeled in software exactly as it's defined in the real world.
Yes, just because an ellipse has two foci, and a circle *apparently* has
one, doesn't mean that we need to create an independent circle class, they
both have the same attributes.  It is an optimization to remove the second
focus for circles.

--
Persistence is futile.
You will be aggregated...

Sat, 24 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

I have to confess that I have no idea what the Ellipse-Circle dilemma is.
Can anyone enlighten me, and all those others that are in the dark.

--
Stephen Pascoe
http://www.chem.leeds.ac.uk/ICAMS/people/stephenp/home.html

Voice: 0113 274 9636 (Home), 0113 233 6597 (Work)

Mon, 26 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

> I have to confess that I have no idea what the Ellipse-Circle dilemma is.
> Can anyone enlighten me, and all those others that are in the dark.

> --
> Stephen Pascoe
> http://www.chem.leeds.ac.uk/ICAMS/people/stephenp/home.html

> Voice: 0113 274 9636 (Home), 0113 233 6597 (Work)

It has to do with sub-classing.  In other words...

Is an ellipse as specialization of a circle (having two foci) or is a
circle a specialization of an ellipse (having only one)?  Could we say
in a circle's case, that it has two foci like the ellipse and they are
just the same point?

Norman
--
Norman Bunn, Director of Operations  |  Java, Smalltalk & Internet
Solutions

(770) 761-8400                       |  2840 Plaza Place, Suite 325
http://www.arscorp.com                    |  Raleigh, NC 27612

Mon, 26 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

might be.  Norman wasn't confused on the issue at all.)

Quote:
>Is an ellipse as specialization of a circle (having two foci) or is a
>circle a specialization of an ellipse (having only one)?  Could we say
>in a circle's case, that it has two foci like the ellipse and they are
>just the same point?

Yes, and no.  From a philosophy of types viewpoint or some such
nonesense, one could discuss which is which.

In computer programming, subclassing is about sharing code.  Someone
described inheritance as "a programmer's hack".  In my experience,

There are protocols, and surely ellipse and circle share some (like
#perimeter?) and don't share some (like #majorAxis and #minorAxis and
#diameter).  (Yes, I know you could put #majorAxis on Circle ...)

And there's subclassing ... that one you do whichever way saves the
most code, and you do it as late in the game as you can stand.

Regards,

Ron Jeffries
Smalltalker
How do I know what I think until I see what I type?

Wed, 28 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

I think it is more than that. I believe that fundamentals are important in
any field, and "simple" problems like this can have major implications.
This problem is anything but simple, and does point out problems in the
theory of OOP as we understand it. There are advantages and disadvantages
in both ellipse as subclass of circle and vice-versa. The basic problem
this points out is that there is more than one class hierarchy depending
on your frame of reference. If you are a mathematician, then a circle is a
subclass of ellipse (a circle is an ellipse). But it doesn't program well
that way. If you are a programmer, then your code looks cleaner with
ellipse as a subclass of circle (add functionality), but there are other
problems (clumsy).

Ultimately, I have come to believe that the "correct" OOP answer is two
class hierarchies: One for the "user" hierarchy, i.e., the mathematicians
viewpoint. One for the programmer,with the objective of
sharing/reusing/minimal code. Unfortunately, this requires you to jump
through hoops (write two hierarchies). However, it is the only way I know

Wed, 28 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

>It has to do with sub-classing.  In other words...

>Is an ellipse as specialization of a circle (having two foci) or is a
>circle a specialization of an ellipse (having only one)?  Could we say
>in a circle's case, that it has two foci like the ellipse and they are
>just the same point?

Well, for my simplistic first impression, it seems to me that a circle
IS_A elipse, but an elipse is not a circle.  What are the arguments in
the other direction?  I'd descend circle from elipse.

-PD

--
--
Patrick Doyle

Wed, 28 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

It's 4:30 am,
I couldn't sleep,
and I had to do something,
so I guess its the circle-ellipse question for me - I enter in the MIDDLE

several writers said ...

Quote:
>>Is an ellipse as specialization of a circle (having two foci) or is a
>>circle a specialization of an ellipse (having only one)?  Could we say
>>in a circle's case, that it has two foci like the ellipse and they are
>>just the same point?

>Well, for my simplistic first impression, it seems to me that a circle

Quote:
>IS_A elipse, but an elipse is not a circle.  What are the arguments in
>the other direction?  I'd descend circle from elipse.

From the algebraic point of view, both ellipse and circle are 2nd degree
curves (the usual 2nd degree algebraic equation in x and y - AX**2+ ... +
F).  The other members of this set are point, hyperbola, and parabola.

Ellipse, point, and circle seem closely related, in that if B**2 - 4AC < 0
then the conic section is a point, ellips, or a circle.

In the same sense that a circle is a special case of the ellipse, the
point is a special case of the circle.  Also, two intersecting lines is a
degenerate case of the hyperbola.

I still wonder about the wisdom of using inheritance to show a
relationship between any of these objects.   However, as far as ellipse
and circle, it is clear that the circle is a special case of the ellipse.
The equation of a circle is a special case of the ellipse.

x**2/(a**2) + y**2/(b**2) = 1  (a**2 = b**2  => circle)

Also, if one views them as intersections of plane and double-cone, then
the circle is also a special case of the ellipse.

Allen

Thu, 29 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

: In computer programming, subclassing is about sharing code.  Someone
: described inheritance as "a programmer's hack".  In my experience,

: There are protocols, and surely ellipse and circle share some (like
: #perimeter?) and don't share some (like #majorAxis and #minorAxis and
: #diameter).  (Yes, I know you could put #majorAxis on Circle ...)

: And there's subclassing ... that one you do whichever way saves the
: most code, and you do it as late in the game as you can stand.

With that philosphy, one will get lost first time when he should do
something really complicated. At the end, if it will work, it will require
more time than without inheritance.

_______________________________________________
Author: Kazimir Majorinc, Zagreb, Croatia

http:   //public.srce.hr/~kmajor (~7min to USA)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One who knows the secret of the 7th stair

Thu, 29 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:

>> It has to do with sub-classing.  In other words...
>> Is an ellipse as specialization of a circle (having two foci) or is a
>> circle a specialization of an ellipse (having only one)?  Could we say
>> in a circle's case, that it has two foci like the ellipse and they are
>> just the same point?
> Well, for my simplistic first impression, it seems to me that a circle
> IS_A elipse, but an elipse is not a circle.  What are the arguments in
> the other direction?  I'd descend circle from elipse.

Imagine the thing's a mutable object in a drawing program.

"elongate by a factor of 2 along the x axis" is a reasonable thing to ask
an ellipse to do, but not a circle.  If Ellipse has behaviours that Circle
doesn't, how can it be a superclass of Circle?  (without crude hacks).

-----------------------------------------------------------------------------

T/L, 2 Haddington Place, Edinburgh EH7 4AE, Scotland       (+44) 131 556 5272
---------------------  Save Scunthorpe from Censorship  ---------------------

Thu, 29 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

: Is an ellipse as specialization of a circle (having two foci) or is a
: circle a specialization of an ellipse (having only one)?  Could we say
: in a circle's case, that it has two foci like the ellipse and they are
: just the same point?

: All in all an interesting academic exercise, but that's about all.

Hardly just an academic exercise, though it is useful as one.

Each time the question arises, I usually see the arguments addressed first
from the standpoint of representation, then behavior.  Of course, it is
possible to implement a system in which either class of shapes is the base
class.  To me, a very convincing argument can be found in the substitution
principle.  Can a circle be substituted for an ellipse?  It depends
entirely on the set of operations the ellipse type represents.  If it
represents an operation that can stretch the shape in one independent
axis, the answer is clearly no.  Subclassing a circle from an ellipse
would lead to violating a constraint that a circle's axese remain equal or
that the "stretch" operation actually do what it advertises.

The best answer is that circle and ellipse derive from a third class that
provides all the traits common to both classes and none of the traits
specific to either.

Fri, 30 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Quote:
> The best answer is that circle and ellipse derive from a third class that
> provides all the traits common to both classes and none of the traits
> specific to either.

In geometry, a circle is an ellipse, but not a stretchable ellipse.  As you
suggest, a three-class hierarchy is appropriate.  However, the base class
should be the (non-stretchable) Ellipse class in order to reflect the
conceptual relationships in geometry.

Ellipse
/   \
/       \
StretchableEllipse     Circle

---

Roger L. Cauvin

Software Engineer
National Instruments

Fri, 30 Jul 1999 03:00:00 GMT
Opinions on Ellipse-Circle dilemma?

Greetings!

Quote:

>>It has to do with sub-classing.  In other words...

>>Is an ellipse as specialization of a circle (having two foci) or is a
>>circle a specialization of an ellipse (having only one)?  Could we say
>>in a circle's case, that it has two foci like the ellipse and they are
>>just the same point?

>  Well, for my simplistic first impression, it seems to me that a circle
>IS_A elipse, but an elipse is not a circle.  What are the arguments in
>the other direction?  I'd descend circle from elipse.

> -PD

>--
>--
>Patrick Doyle

CLASS Ellipse:
METHOD setAxesLength( real major, real minor )

CLASS Circle: SUBCLASS Ellipse

A: Circle
B: Ellipse

A.Create
B := A
B.setAxesLength( 5, 10 )

Hmmmm, doesn't work too well does it?

The problem of matching subtypes is that you also match interfaces, which means
that any subclass better support what its superclass can be told to do.

Ed

Fri, 30 Jul 1999 03:00:00 GMT

 Page 1 of 2 [ 25 post ] Go to page: [1] [2]

Relevant Pages