Re: OO Concept: Liskov Substitution Principle



howa wrote:
Hi,

Just read an article talking about the LSP in term of OO design:
http://www.objectmentor.com/resources/articles/lsp.pdf

The article said Rectangle class should not be a superclass of Square
class.

There are perfectly valid ways to implement Square as a subclass of Rectangle.

--
Lew
.



Relevant Pages

  • OO Concept: Liskov Substitution Principle
    ... The article said Rectangle class should not be a superclass of Square ... so how you would design the Rectangle & Square class? ...
    (comp.lang.java.programmer)
  • Re: OO Concept: Liskov Substitution Principle
    ... The article said Rectangle class should not be a superclass of Square ... so how you would design the Rectangle & Square class? ... The problem with compatibility is that SquareMatrix assumes that its two dimensions are equal; since these dimensions can only be affected at initialization, thereby rendering this contractual incompatibility moot. ... However, in the end, we decide that requiring a separate SquareMatrix class is pointless since a 3x2 matrix multiplied by a 2x3 matrix is a square matrix even if its type is merely a banal Matrix, rendering the entire discussion moot. ...
    (comp.lang.java.programmer)