Simplest Liskov Substitution Principle with Code Example

Simplest Liskov Substitution Principle with Code Example

Code Radiance

3 года назад

13,017 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@vaatsaate
@vaatsaate - 06.01.2023 19:41

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 ?

Ответить
@angel_machariel
@angel_machariel - 29.07.2022 22:13

Opinion is not part of LSP. This si a bad example.

Ответить
@sniperated
@sniperated - 17.05.2022 02:47

Ketchup on pizza is violating many taste principles

Ответить
@behnamseydabadi8819
@behnamseydabadi8819 - 26.04.2022 13:02

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?

Ответить
@priyankagarg7449
@priyankagarg7449 - 04.02.2022 19:06

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?

Ответить
@praktycznewskazowki6733
@praktycznewskazowki6733 - 22.01.2022 17:31

pizzza is good :D

Ответить
@mos90
@mos90 - 11.07.2021 10:35

thanks. one problem. pizza is pronounced "peet .suh"

Ответить
@adamnorman85
@adamnorman85 - 04.03.2021 19:16

great thanx

Ответить
@prashantagrawal5194
@prashantagrawal5194 - 02.03.2021 10:49

Nice

Ответить
@JD-sn1lr
@JD-sn1lr - 23.12.2020 22:55

Great explanation! Thank you so much.

Ответить