LSP的意义:
一、改进已有实现。例如程序最开始实现时采用了低效的排序算法,改进时使用LSP实现更高效的排序算法。
二、指导程序开发。告诉我们如何组织类和子类(subtype),子类的方法(非私有方法)要符合contract。
三、改进抽象设计。如果一个子类中的实现违反了LSP,那么是不是考虑抽象或者设计出了问题。
补充:
Liskov是美国历史上第一个女计算机博士,曾获得过图灵奖。
In 1968 she became one of the first women in the United States to be awarded a Ph.D from a computer science department when she was awarded her degree from Stanford University. At Stanford she worked with John McCarthy and was supported to work in artificial intelligence.
https://en.wikipedia.org/wiki/Barbara_Liskov
展开