Loading ...
Sorry, an error occurred while loading the content.
 

Re: [XP] Circle/Ellipse dilemma

Expand Messages
  • Ron Jeffries
    ... So this method would return a single point and radius in the one case, and two points and one length in the other case? What kind of object would this
    Message 1 of 120 , Nov 30, 2003
      On Sunday, November 30, 2003, at 12:09:43 PM, Steve Howell wrote:

      > 1) Circle and Ellipse both have a method called
      > getDefininingCoordinatesAndLength.
      > 2) Circle would delegate out to getCenterAndRadius.
      > 3) Ellipse would delegate out to getFociAndMajorAxisLength.

      So this method would return a single point and radius in the one case, and
      two points and one length in the other case?

      What kind of object would this getDefininingCoordinatesAndLength method be
      returning, and how would one use it?

      > If this kind of refactoring seems to pose an unsolvable paradox to
      > object purists, then maybe there is something wrong with object purism. :)

      Ahem.

      Ron Jeffries
      www.XProgramming.com
      I must create a system, or be enslaved by another man's;
      I will not reason and compare; my business is to create. --William Blake
    • Keith Ray
      ... example of bad OO: class point { float x, y (and methods...) }; class circle extends point { float radius; (methods treat inherited x,y as center) };
      Message 120 of 120 , Dec 2, 2003
        On Tuesday, December 2, 2003, at 05:08 PM, Amir Kolsky wrote:

        >> Indeed, the data structure that represents an ellipse has too many
        > variables to efficiently represent a circle.
        >
        > Yup, and by virtue of the bad smell, we should know that there's
        > something immutably wrong with even trying to get to a circle by
        > subclassing ellipse...

        example of "bad" OO:

        class point { float x, y (and methods...) };

        class circle extends point { float radius; (methods treat inherited x,y
        as center) };

        class ellipse extends circle { point secondLocus; (methods treat
        inherited x,y as first locus) };

        class square extends point { float sidelength; (methods treat inherited
        x,y as top-left of square) };

        class rectangle extends square { float otherSideLength; (ad nauseum) };

        --
        C. Keith Ray
        <http://homepage.mac.com/keithray/blog/index.html>
        <http://homepage.mac.com/keithray/xpminifaq.html>
        <http://homepage.mac.com/keithray/resume2.html>
      Your message has been successfully submitted and would be delivered to recipients shortly.