![]() ![]() ![]() Φ (y) should be true for objects y of type S where S is a subtype of T. LSP was given by Barbara Liskov in a 1988 conference keynote address titled Data abstraction and hierarchy, According to Wikipedia definition is, Let ϕ (x) be a property provable about objects x of type T. Too much talking!!! Let's take a look at the actual definition, You can still have fully functional inherited code but it might not be conceptually correct & prone to break with a new set of requirements. Liskov's principle is nothing but a way to validate if the inheritance pattern you are using is valid conceptually or not. If this sounds like your code then there is a better way to write parent-child classes using the concept of inheritance. We are used to writing inheritance code by thinking that if there is some shared piece of code & that has some similar behavior that is can be extended by other classes then create a parent class with the code & behavior & you are done for the day! It actually alters your thinking of how you actually do inheritance in your code. ![]() Liskov's substitution principle actually helps you write better code where inheritance is used. Nope! my friend, you cannot be more wrong than this. You might be wondering if this sounds like some mathematical principle in computer science that is hardly used in the daily life of software developers. Liskov's substitution principle is a part of the S.O.L.I.D design principle where L is for Liskov's substitution principle. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |