News for hackers. Stuff that matters.
Re:Inheritance Often Doesn't Make Sense by kqr on Saturday March 17, 2018 @12:30PM (#16607668)
> No, no: "If you ask me for any object that can have independent width and height, and you reject a Square, you are..." right, of course. It depends on the properties that define what a Rectangle and a Square are in your code.

I think you nailed an important distinction here, but maybe used the wrong words in doing so. The correct definition of a rectangle, with this interpretation, is any object that can change its width and height independently.

I'm just not sure that this is such a sensible definition of a rectangle.

In my mind, the word "rectangle" is a description of how things are in this instant, not a description of in which ways something can change in the future. The latter is a valid concept and something we need a word for, but I'm not sure "rectangle" is such a good candidate.

This also opens up for a solution to the problem:

- In the first sense, rectangle > square. A rectangle has four straight angles, and squares are rectangles where both lenghts happen to be the same.

- In the second sense, square > rectangle. Squares are things which can be scaled, and rectangles are squares which can scale each axis independently.

Re:Inheritance Often Doesn't Make Sense by PKop on Saturday March 17, 2018 @01:17PM (#16607949)
I don't think the "that can change" characteristic is important here.

You can declare that "for all values of width and height, w does not have to equal h" to be valid. Mutability is irrelevant.

Re:Inheritance Often Doesn't Make Sense by kqr on Saturday March 17, 2018 @01:30PM (#16608027)
But a rectangle as traditionally defined can have equal dimensions. Consider the rectangle whose width slowly grows to be longer than the height. Surely it does not skip a value because it happens to equal the height?
Re:Inheritance Often Doesn't Make Sense by PKop on Saturday March 17, 2018 @01:35PM (#16608051)
"does not have to be equal" != "can't be equal".

The set of all possible rectangles have w and h that can be different (or the same) values.