定义
里氏替换原则(Liskov Substitution Principle, LSP)确保继承表现为一种类型扩展而非类型的重定义。具体而言,如果类型 S 是类型 T 的子类型,则类型 T 的对象可以在程序中被类型 S 的对象替换(即,类型…
SOLID是五大设计原则的首字母简写,最早出现于出自Robert Martin(罗伯特. 马丁)的《架构整洁之道》第三章设计原则。他们分别是
single Responsibility Principle:单一职责原则 Open Closed Principle:开闭原则 Liskov…
前言
今天来学习 SOLID 中的 L:里氏替换原则。它的英文翻译是 Liskov Substitution Principle,缩写为 LSP。 英文原话是: Functions that use points of references of base classes must be able to use objects of derived classes withou…