Answer the question
In order to leave comments, you need to log in
SOLID.LSP + OOP.Polymorphism = contradiction?
After studying various sources about the Liskov Substitutioin Principle , I did not find an answer to the question:
How does LSP combine with polymorphism in OOP?
After all, judging by the definition, LSP instructs the heirs to preserve the behavior (contract) of the base class.
Whereas polymorphism is the ability to change the behavior of the methods of the base class in the heirs. If we interpret LSP literally, then I see an unambiguous contradiction in these approaches.
Actually, how to resolve it?
Answer the question
In order to leave comments, you need to log in
LSP instructs descendants to preserve the behavior (contract) of the base class.
There was a requirement - to change the format of some reports to CSV.
Whereas polymorphism is the ability to change the behavior of the methods of the base class in the heirs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question