里氏替换原则
跳转到导航
跳转到搜索
Template:NoteTA Template:Solid principles

在面向对象的程序设计中,里氏替换原则(Liskov Substitution principle)是对子类型的特别定义。它由芭芭拉·利斯科夫(Barbara Liskov)在1987年在一次会议上名为“数据的抽象与层次”的演说中首先提出。[1]
里氏替换原则的内容可以描述为: “派生类(子类)对象可以在程式中代替其基类(超类)对象。” 以上内容并非利斯科夫的原文,而是译自罗伯特·马丁(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代換原則。
引用
參考文獻
Template:Refbegin 一般參考
- Template:Cite book This paper surveys various notions of behavioral subtyping, including Liskov and Wing's.
- Template:Cite conference
An updated version appeared: Template:Cite techreport The formalization of the principle by its authors. - Template:Cite book Contains a gentler introduction to behavioral subtyping in its various forms in chapter 2.
- Template:Cite web An article popular in the object-oriented programming community that gives several examples of LSP violations.
- Template:Cite book This paper discusses LSP in the mentioned context.
具體參考
- Template:Cite journal A keynote address in which Liskov first formulated the principle.
- Template:Cite book
参閲
- SOLID - “SOLID”中的 L 指代了里氏替换原则
- 類型簽名
- Template:Le(Referential transparency)
- Template:Le(Refinement (computing))
- Template:Le(Composition over inheritance)