Комментарии:
Very nice explanation... specially pizza example.. Two questions - Q1) you said "its all about behavior and not attributes", which means if Pizza class is deriving from HealthyFood, then LSP will be violated only if we add Cheese in GatherIngridients ? If we dont add cheese and ketchup in Pizza, it will not be LSP violation, correct ? Q2) what I am doing inside child class GatherIngridients() methdo will decide if LSP is followed or violated ?
ОтветитьOpinion is not part of LSP. This si a bad example.
ОтветитьKetchup on pizza is violating many taste principles
ОтветитьGreat. Now I get it. Liskov is talking about behavior, not details of behavior.
Yes when you replace child object with father object, the result changes but the program does the job.
Liskov is not looking for result, its looking for state of program to be functional.
Am i wrong?
So in this case, to avoid the violation of LSP, Pizza class won't extend HealthyFood class. And both will be like two distinct class with no relation. Right?
Ответитьpizzza is good :D
Ответитьthanks. one problem. pizza is pronounced "peet .suh"
Ответитьgreat thanx
ОтветитьNice
ОтветитьGreat explanation! Thank you so much.
Ответить