面向对象的程式设计中,里氏替换原则(Liskov Substitution principle)是对子类型的特别定义。它由芭芭拉·利斯科夫(Barbara Liskov)在1987年在一次会议上名为“数据的抽象与层次”的演说中首先提出。[1]

Portrait of Barbara Liskov
里氏替换原则由芭芭拉·利斯科夫提出,照片摄于2010年.

里氏替换原则的内容可以描述为: “派生类(子类)对象可以在程序中代替其基类(超类)对象。” 以上内容并非利斯科夫的原文,而是译自罗伯特·马丁(Robert Martin)对原文的解读。其原文为:

Let be a property provable about objects of type . Then should be true for objects of type where is a subtype of .

芭芭拉·利斯科夫周以真(Jeannette Wing)在1994年发表论文并提出以上的Liskov代换原则

引用

参考文献

参阅

外部链接

Wikiwand in your browser!

Seamless Wikipedia browsing. On steroids.

Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.

Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.