"Square is-a Rectangle", the classic example of inheritance failing, doesn't fail when the objects are immutable. I never noticed before.
Conversation
How would it even fail for a mutable Square/Rect? Or is Rect a subclass of (mutable) BezierPath or Polygon?
2
Replying to
Quote Tweet
Replying to @stevedekorte
@stevedekorte @garybernhardt Fails Liskov substitution because the domain of setSize() is smaller on Square than on Rectangle.
It occurs to me that NSWindow solves this (arguably) with more mutability: It has an aspectRatio property.


