August 2018
Intermediate to advanced
332 pages
9h 12m
English
In other cases, however, the way LSP is broken is not so clear or obvious that a tool can automatically identify it for us, and we have to rely upon careful code inspection when doing a code review.
Cases where contracts are modified are particularly harder to detect automatically. Given that the entire idea of LSP is that subclasses can be used by clients just like their parent class, it must also be true that contracts are correctly preserved on the hierarchy.
Remember from Chapter 3, General Traits of Good Code, that, when designing by contract, the contract between the client and supplier sets some rules—the client must provide the preconditions to the method, which the supplier might validate, and ...