NOTE

Liskov Substitution Principle

The Liskov substitution principle requires subclasses to preserve the meaning and expectations of parent-class methods. These notes examine inheritance and extension through it.

Software Architecture & EngineeringCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is the Liskov Substitution Principle?

Do not break the inheritance hierarchy. When a subclass overrides a method and changes its behavior, it should not affect the meaning of the parent-class method.

It applies the open–closed principle to inheritance.

2. Why Is the Liskov Substitution Principle Needed?

Improve software reusability through inheritance.

3. Implementing the Liskov Substitution Principle

A subclass can implement abstract methods of the parent class, but must not override non-abstract methods of the parent class.

A subclass can add methods specific to itself.

4. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub