Re: 7.0 wishlist?



Joshua Cranmer <Pidgeot18@xxxxxxxxxxxxxxx> wrote:
Andreas Leitgeb wrote:
Joshua Cranmer <Pidgeot18@xxxxxxxxxxxxxxx> wrote:
Note, for example, that making a Square class extend a Rectangle
[...] would fail to match the Rectangle's contract.
what type of rectangle-related contract do you have in mind?
I hope it is not something like "width!=height must be allowed"
[example snipped, as it boiled down to exactly my prognose]

Whether Square breaks Rectangle's contracts of course depends on the
contracts put up by Rectangle. If it contains goofy contracts then,
indeed, Square may not match those.

The idea that changing the height does not change the width is what is
violated.
And that is, what I consider an #1 example of a goofy contract.

PS: but then again, the Square could override setWidth and setHeight
to throw a certain exception and instead offer a setSize...
The Rectangle class would have to "allow" the throwing of exceptions
in its contract for that.
.



Relevant Pages

  • I was registering vitamins to competitive Ben, whos pricing between the seeds ward.
    ... square, grows from it, consuming too. ... contract never. ... prides award amid smart booklets, ...
    (sci.crypt)
  • 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: 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: 7.0 wishlist?
    ... making a Square class extend a Rectangle ... does not actually work since it would fail to match the Rectangle's ... what type of rectangle-related contract do you have in mind, ...
    (comp.lang.java.programmer)
  • DbC & TDD: Fizzing Fusion or Flat Fizzle? [2/2]
    ... an invariant is a general clause which ... information: the contract. ... The short form retains headers and assertions of exported features, ... exception handling -- handling abnormal cases. ...
    (comp.object)