Contents
What does Liskov Substitution Principle?
The Liskov Substitution Principle in practical software development. The principle defines that objects of a superclass shall be replaceable with objects of its subclasses without breaking the application. That requires the objects of your subclasses to behave in the same way as the objects of your superclass.
Is Liskov Substitution polymorphism?
The Liskov Substitution Principle (LSP) is strongly related to subtyping polymorphism. Based on subtyping polymorphism in an object-oriented language, a derived object can be substituted with its parent type. For example, if we have a Car object, it can be used in the code as a Vehicle .
What is the benefit of Liskov Substitution Principle?
If your code adheres to the Liskov Substitution Principle you have many benefits. These include: code re-usability, reduced coupling, and easier maintenance.
Why is it important to consider the Liskov Substitution Principle?
Take advantage of Liskov Substitution Principle to reduce coupling and facilitate code reusability in your application. LSP (Liskov Substitution Principle) is a fundamental principle of OOP and states that derived classes should be able to extend their base classes without changing their behavior.
What is principle of substitution in economics?
The principle of substitution states that the upper limit of value tends to be set by the cost of acquiring an equally desirable substitute, assuming no untimely delays. A prudent investor would pay no more for an income-producing property than it would cost to build or purchase a similar property.
Which of the following is a code smell that the Liskov Substitution Principle is violated?
A common code smell that frequently indicates an LSP violation is the presence of type checking code within a code block that should be polymorphic.
What is Dependency Inversion principle in Java?
The Dependency Inversion Principle (DIP) states that high level modules should not depend on low level modules; both should depend on abstractions. Abstractions should not depend on details. Details should depend upon abstractions.