Liskov Substitution Principle

Publié le: 10 octobre 2023
sur la chaîne: ProgRank
1,259
25

Liskov's notion of a behavioral subtype defines a notion of substitutability for objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g. correctness).

Liskov Substitution Principle (LSP) is all about well-designed inheritance, when you inherit from a base class, you should be able to substitute your derived class with the base class without things going wrong. Otherwise,
you have used inheritance incorrectly!

In mathematics, a Square is a Rectangle. Square derived from Rectangle
Imagine you had SetWidth and SetHeight methods on your Rectangle base class; this seems perfectly logical. if your Rectangle reference pointed to a Square, then SetWidth and SetHeight don't make sense?

The major difference between a square and a rectangle is that a square has all its sides equal, whereas a rectangle has its opposite sides equal.

=======================================================

liskov substitution principle in Hindi,liskov substitution principle,liskov,LSP liskov substitution principle java,liskov violation,liskov substitution,liskov substitution principle react,liskov substitution principle c#,liskov substitution principle java,liskov substitution explained,liskov substitution violation,liskov substitution vs dependency inversion


Sur cette page du site, vous pouvez voir la vidéo en ligne Liskov Substitution Principle durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur ProgRank 10 octobre 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,259 fois et il a aimé 25 téléspectateurs. Bon visionnage!