The difference between liskov substitution principle and interface segregation principle

LSP: The subtype must honor the contracts it promises.

ISP: The caller shouldn’t depend on more of the base type’s interface than it needs.

Where they fit: If you apply the ISP, you use only a slice of the receiver’s full interface. But according to LSP, the receiver must still honor that slice.

If you fail to apply ISP, there can be a temptation to violate LSP. Because “this method doesn’t matter, it won’t actually be called.”

Leave a Comment

tech