Liskov Substitution Principle layman term explanation using machine learning example

Viewed 30

I am studding SOLID principle and completed S.O , I got stuck at L which is (Liskov Substitution Principle) I have referred some many blogs but couldn't get proper explanation

Can someone explain it with real time example in machine learning

What I meant by real time examples in machine learning is like this which they presented in this blog but they didn't mention example for liskov if any one have answer please share it

1 Answers

Uncle Bob used to explain it using cars as an example. A car is a higher concept or in terms of a programming language e.g. a base class or an interface. Concrete cars from different brands are supposed to behave according to the specification given by the general car concept so that someone who is used to drive a car is not surprised when driving a car of a different brand. Now to the LSP. As someone (a client) who learned driving a car in general you expect that any car tuns to the left in case you turn the steering wheel to the left. If some concrete car of so some brand (a subtype of car) behaves not according to this expectation it is violating the LSP.

Related