Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The real problem is that your interface doesn't actually describe a rectangle. It describes a mutable object whose current state is one rectangle, but whose state at a different point in time might be a completely different rectangle. Lest you think otherwise: removing the setters doesn't change anything.

If you could define a type whose instances are actual rectangles, and then another type whose instances are rectangles whose width and height are equal (as a refinement of the original type of rectangles), it'd be clear as daylight that squares are rectangles.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: