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

Re[2]: [XP] Circle/Ellipse dilemma

Expand Messages
  • Michael Feathers
    ... JBR Yes, but it blows the Decorator pattern out of the water. I m not advocating that but when you are driving it is nice to know where the the pavement
    Message 1 of 120 , Dec 1, 2003
    • 0 Attachment
      >> KR> This really has nothing to do with XP.
      >>
      >> Here's food for thought.. if you have a class hierarchy where you
      >> have only one definition for each method (no overrides) you
      >> dramatically reduce your chances of an LSP violation. See why?
      >>
      >> I guess having more than one definition for a method is a kind of
      >> duplication, eh?

      JBR> Yes, but it blows the Decorator pattern out of the water.

      I'm not advocating that but when you are driving it is nice to
      know where the the pavement is slick.

      BTW, don't tease me with the chance to get rid of decorator again :-)

      Michael Feathers
      www.objectmentor.com
    • 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
      • 0 Attachment
        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.