Tagged Questions
73
votes
13answers
6k views
Why would Square inheriting from Rectangle be problematic if we override the SetWidth and SetHeight methods?
If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design?
I have heard people say:
If you made Square derive from Rectangle, then a Square ...
0
votes
1answer
54 views
Would it make sense to add parameters of an inferred type to inheritance?
I'll write this in PHP (where this thought originated), but this is generic to any object-orientated language. Basically, this is an addition to abstract classes that defines the implementation of its ...
5
votes
2answers
786 views
How does strengthening of pre conditions and weakening of post conditions violate Liskov Substitution principle?
I read that Liskov substitution principle is violated if :
Pre conditions are strengthened .
Post conditions are eased out.
But I don't get fully yet how these two points would violate Liskov ...