Hacker News new | ask | show | jobs
by 1718627440 300 days ago
> if all it did was substitute for X, and behave exactly the same way?

LSP is about behaviour existing in the supertype. Adding behaviour doesn't violate LSP.

> In a graphics program, an ellipse and rectangle are substitutable in that they have a draw() method and others, so that they plug into the framework.

The behaviour in question means it draws something. It can draw something different every time, and not violate LSP here.