Re: 7.0 wishlist?



Joshua Cranmer <Pidgeot18@xxxxxxxxxxxxxxx> wrote:
Note, for example, that
making a Square class extend a Rectangle (since a Square is-a Rectangle)
does not actually work since it would fail to match the Rectangle's
contract.

I may not understand your example in all its possible deepness, but
what type of rectangle-related contract do you have in mind, that is
not met by a square? I hope it is not something like "width!=height
must be allowed": such types of contracts would thwart almost every
"is-a" relation.

.



Relevant Pages

  • Re: 7.0 wishlist?
    ... making a Square class extend a Rectangle does not actually work since it would fail to match the Rectangle's contract. ... A more general way of putting it is that it violates the contract that properties are distinct and individually modifiable without affecting others. ...
    (comp.lang.java.programmer)
  • Re: Why is OO Popular?
    ... Ellipses are circles is horribly wrong and squares are rectangles is ... Circles are ellipses breaks LSP ... > rectangle can be changed independently ... square value in a rectangle variable or a square value in a square ...
    (comp.object)
  • Re: Agile Ecosystems Vs (Rational) Unified Process
    ... > conflict between Rectangle and Square, and not one line of code ... and practice on the other are seen as mostly independent and separate ... Google Home - Advertising Programs - Business Solutions - About Google ...
    (comp.object)
  • Re: 7.0 wishlist?
    ... making a Square class extend a Rectangle ... what type of rectangle-related contract do you have in mind, ... Square is-a rectangle doesn't work for mutable types: if you modify ...
    (comp.lang.java.programmer)
  • Re: SubTyping versus SubClassing
    ... small subset of ones used in mathematics. ... >> which you'd better have a square for each rectangle, ... Operations defined on the types are that theorems we have to prove ...
    (comp.object)