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

Re: [XP] Circle/Ellipse dilemma

Expand Messages
  • Shawn W. Devlin
    ... What is the difference between Type and Behaviour inheritance? If Type Inheritance is akin to interfaces in Java, is Behaviour inheritance simply
    Message 1 of 120 , Dec 1 9:31 AM
      WATKINS, Robert wrote:

      >If you can break the mental connection between the type inheritance and the
      >behaviour inheritance, you'll (probably) end up being a better OO
      >programmer. :)
      >
      >

      What is the difference between Type and Behaviour inheritance? If Type
      Inheritance is akin to interfaces in Java, is Behaviour inheritance
      simply subclassing?

      --
      Shawn
    • 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 6:15 PM
        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.