Introduction 介绍

Don't worry, the Liskov Substitution Principle is a lot easier to understand than it sounds. This principle states that you should be able to use any implementation of an abstraction in any place that accepts that abstraction. But, let's make this a little simpler. In plain English, the principle states that if a class uses an implementation of an interface, it must be able to use any implementation of that interface without requiring any modifications.

别担心,里氏替换原则读起来吓人学起来简单。该原则要求:一个抽象的任意一个实现,可以被用在任何需要该抽象的地方。读起来绕口,用普通人的话来解释一下。该原则规定:如果一个类使用了一个接口的一个实现类,那么该接口的任何其他实现类也可以被这里直接使用,不用做出任何修改。

Liskov Substitution Principle 里氏替换原则

This principle states that objects should be replaceable with instances of their sub-types without altering the correctness of that program.

该原则规定对象应该可以被该对象子类的实例所替换,并且不会影响到程序的正确性。

results matching ""

    No results matching ""