In object-oriented programming, the Liskov substitution principle is a particular definition of subtype that was introduced by Barbara Liskov in a 1987 conference keynote address entitled Data abstraction and hierarchy.
Liskov formulated the principle succinctly in a subsequent paper as follows:
Let q(x) be a property provable about objects x of type T. Then q(y) should be true for objects y of type S where S is a subtype of T.
Thus, Liskov's notion of "subtype" defines the notion of substitutability; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g., correctness).
本文介绍了面向对象编程中的一项核心原则——里氏替换原则。该原则由Barbara Liskov提出,强调子类型应当能够在不改变程序正确性的前提下替换其基类型。文章详细阐述了这一原则的具体定义及其在软件设计中的重要性。
580

被折叠的 条评论
为什么被折叠?



