Monday, May 1, 2017

Compromise, perfection and the Liskov Substitution Principle

There are rare occasions when it is more expedient to accept a subtle flaw in polymorphic behavior than to attempt to manipulate the design into complete LSP compliance. Accepting compromise instead of pursuing perfection is an engineering trade-off. A good engineer learns when compromise is more profitable than perfection. However, conformance to the LSP should not be surrendered lightly. The guarantee that a subclass will always work where its base classes are used is a powerful way to manage complexity. Once it is forsaken, we must consider each subclass individually.

Robert C. Martin, "LSP: The Liskov Substitution Principle", in Agile Software
Development: Principles, Patterns, and Practices
, 122.

No comments

Post a Comment