设计原则 单一职责原则Single responsibility principle(SRP) A class should have a single purpose and only one reason to change If a class has more than one responsibility, then the responsibilities becomes coup
定义 里氏替换原则(Liskov Substitution Principle, LSP)确保继承表现为一种类型扩展而非类型的重定义。具体而言,如果类型 S 是类型 T 的子类型,则类型 T 的对象可以在程序中被类型 S 的对象替换(即,类型 S 的对象可以替代类型 T 的对象),而不改变该程序的期望行为。 应用场景 LSP 应用于任何基于继承的设计中,确保子类的行为符合父类的预期。它是多态