Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - definition - "principle of substitution"

Tags:

java

I read a summary which always use the definition "principle of substitution" when it talk about inheritance. But It doesn't explain the meaning of this principle.

What is this principle?

Thank you.

like image 314
Tom Avatar asked Dec 04 '22 21:12

Tom


1 Answers

It means plainly: a subclass must honor the contract set by the super class.

If you extend a super class, you should read its document and implement as it dictates. That's all.

If I hear one more time "Liskov substitution" I'm going to kill a kitten.

like image 160
irreputable Avatar answered Dec 24 '22 04:12

irreputable