Open/Closed Principle Explained - SOLID Design Principles

Open/Closed Principle Explained - SOLID Design Principles

Web Dev Simplified

4 года назад

133,535 Просмотров

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


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

@tusharsingh7926
@tusharsingh7926 - 08.12.2023 07:59

Thank You So Much for this wonderful video................🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

Ответить
@donaldjr.labajo5687
@donaldjr.labajo5687 - 03.12.2023 17:29

Great tutorial! Just one question:
Shouldn't the <QuestionType>Question classes not know the printing behavior i.e printQuestionChoices()?
It might sound better to say rangeQuestion.getChoices(), which returns an array of the choices and then:

printQuiz(quiz) {
quiz.getChoices().map((choice) => console.log(choice));
}

Just an idea :D

Ответить
@a.z.b.1916
@a.z.b.1916 - 24.10.2023 16:24

Its a bit difficult to immediately understand the benefit of this approach.
What if business decides to introduce a time limit for each type of questions(different types would have different time limits)?
You would need to update all the components separately but you would also need to update 'printQuiz' as well to call for the relevant method each time....

Ответить
@gyros9162
@gyros9162 - 02.10.2023 08:59

The explanation is brilliant

Ответить
@khanisanthony2437
@khanisanthony2437 - 13.08.2023 19:20

Umm, what if the questions is come from external sources like database.

For each data we got, we still need if statements to construct the class correctly.

Let say,

if type === "multiple" then new MultipleChoice()
else if type === "single" then new SingleChoice()

does this violates the ocp rules?
pardon for my noob question 😊

Ответить
@user-uz3qf5uf9l
@user-uz3qf5uf9l - 29.07.2023 08:53

wow the best ive seen so far !

Ответить
@haariskhatri
@haariskhatri - 06.07.2023 10:31

Suppose you're fetching these details from a mongoose collectiion . The result is an array of objects with type and all details . How would one implement this principle then ?

Ответить
@devjony
@devjony - 28.06.2023 06:05

This is quality content

Ответить
@scottldn
@scottldn - 16.06.2023 13:53

Brillaint!

Ответить
@vrojak7636
@vrojak7636 - 02.06.2023 00:46

Best explanation of the concept, and I searched quite a bit.

Ответить
@kphuang
@kphuang - 19.05.2023 22:05

thanks for the great example explaining open closed principle.
the following question is what about c++ example since c++ cannot put objects of different classes into an array?

Ответить
@atuldubey8146
@atuldubey8146 - 17.05.2023 11:13

Excellent Explanation.

Ответить
@caiquevallim2209
@caiquevallim2209 - 03.05.2023 02:35

I understood and I liked how you explained with js and one bad point that I can see with js is because we cannot declare interfaces to be implemented and then we need to make sure that the name of the method is really the same between those classes and having an interface to declare this method would be better because we could create RangeQuestion class implementing idk "PrintableOption" class in order to not worry about writing the method with the same name

Ответить
@doniaelfouly4142
@doniaelfouly4142 - 15.04.2023 13:59

thanks

Ответить
@vision_reflect
@vision_reflect - 22.03.2023 18:08

I need source code Please

Ответить
@thinktwice5035
@thinktwice5035 - 22.03.2023 16:59

Hi Kyle, but what if another new question has to output more than description and choices. How to implement that within the printQuiz() ?

Ответить
@rahimco-su3sc
@rahimco-su3sc - 09.03.2023 13:56

i really appreciate your efforts !! thanks a lot

Ответить
@gmjitendra
@gmjitendra - 09.03.2023 08:13

Excellent!

Ответить
@Halston.
@Halston. - 06.03.2023 00:42

I think I finally understand this principle after reading about it numerous times over the years and watching other videos. Good example, thanks!

Ответить
@maykefernandesdossantos7374
@maykefernandesdossantos7374 - 07.01.2023 15:12

Nice video! already a subscriber!
But could you also include in the SOLID videos how to solve the same problems but in FP not only OOP, just for curiosity.

Ответить
@AndresSerron
@AndresSerron - 19.12.2022 12:36

Nice!
Good Stuff.

Ответить
@WOLKsite
@WOLKsite - 19.12.2022 11:33

I figure a case where if statements are not in violation is in, for instance, algorithms, where you may be comparing index or key values, etc. for for instance sorting operations.

One concern I have in regards to Solid thus far is that it seems to create redundancies, which in turn may lead to more changes being needed. If, for example, two classes use an identical implementation of the same function, if you modify one, you're likely to want to modify the other...

Ответить
@ilanle
@ilanle - 16.12.2022 02:49

You are very good 👏

Ответить
@TheNorthRemember
@TheNorthRemember - 22.11.2022 23:28

js is stupid

Ответить
@samerkayali4525
@samerkayali4525 - 21.11.2022 12:46

Best explanation ever!

Ответить
@ibrahimyoussef4489
@ibrahimyoussef4489 - 11.11.2022 17:17

you are not the one should thanks us , we are

Ответить
@kevingreetham4175
@kevingreetham4175 - 09.11.2022 17:45

What if the method requires different arguments to achieve its functionality? Then how would we implement that? Surely we wouldn’t know what to pass in ? Your great btw Kyle.

Ответить
@kevingreetham4175
@kevingreetham4175 - 09.11.2022 04:54

I have a problem doing this in MVC pattern because a lot of my else if statements target and mutate models in seperate classes, which means my version of the printQuestionChoicr relies on three other classes. It’s a game of monopoly I made. E.g my polymorphic method would each call methods of other objects and since my objects are instantiated inside the controller !

Ответить
@cotixmol
@cotixmol - 05.11.2022 22:25

Hi Kyle! Is there a repository of the SOLID code? I couldn't find it in Github! :(
Thanks for the content!

Ответить
@ericabutts2906
@ericabutts2906 - 05.11.2022 07:50

Great

Ответить
@LABETONETA
@LABETONETA - 04.11.2022 01:57

This was really clear, very clever example, Thanks!

Ответить
@zuzukouzina-original
@zuzukouzina-original - 18.10.2022 22:30

This is a good explanation of O/C principle

Ответить
@affafa100
@affafa100 - 12.10.2022 14:39

Main line was: This principle allows you to extend some code without actually making changes to the code being extended.

Ответить
@Kim-by5uy
@Kim-by5uy - 30.09.2022 19:07

this channel and net ninja have changed my programming life

Ответить
@jffrysith4365
@jffrysith4365 - 30.09.2022 06:45

thank you so much, that makes it so much easier to understand.
If I understand correctly, that means your program should be able to be extended without modifying it. As modifying a class can modify it's functionality with other dependencies, but if we just extend the class, it will not affect those dependencies.

Ответить
@yahayaoyinkansola8258
@yahayaoyinkansola8258 - 13.09.2022 19:45

This was really well explained, thank you so much for the clear explanation. I am definitely going to watch the remaining videos you did on SOLID

Ответить
@aminuabdulsalami4325
@aminuabdulsalami4325 - 22.08.2022 10:39

You are an excellent teacher.

Ответить
@hongmeigeng3713
@hongmeigeng3713 - 11.08.2022 12:27

awesome video, thanks author.

Ответить
@ttl5842
@ttl5842 - 29.07.2022 18:07

your sample code is amazing, I'd really appreciate it's elegant logic.

Ответить
@nasirmovlamov
@nasirmovlamov - 28.07.2022 18:06

Great example and explaining

Ответить
@brunofilgueiras3518
@brunofilgueiras3518 - 27.07.2022 02:58

can I give this video a thousand likes???????

Ответить
@csandreas1
@csandreas1 - 23.07.2022 20:48

I have been programming like that without knowing the open close principle

Ответить
@ikemkrueger
@ikemkrueger - 18.07.2022 13:49

As I understood the open/closed principle: Open for new "data", closed in behavior.

Ответить
@ahmedshehatah1822
@ahmedshehatah1822 - 16.07.2022 04:17

Amazing 😀 thank you 😊

Ответить
@knightmarerip711
@knightmarerip711 - 05.06.2022 00:23

Is it just me or does this seem more like a Liskov Substitution sample? I think Open-Close is more for extending the functionality of a call without changing the main class. For this, I'd make use of the "extends" key word. Still this was really well explained.

Ответить
@paulodonovanmusic
@paulodonovanmusic - 23.05.2022 10:37

What’s the difference between this and the Command Pattern?

Ответить
@thestringsguy3608
@thestringsguy3608 - 21.05.2022 13:05

That's a genius explanation!!

Ответить
@tjserencio
@tjserencio - 12.05.2022 20:38

This is really good. Thanks for sharing 👌👌

Ответить
@ariassingh462
@ariassingh462 - 09.05.2022 23:35

Makes no sense. You had to do more work following the open-close principle. Downvoted.

Ответить
@janmichaelbesinga3867
@janmichaelbesinga3867 - 07.05.2022 04:38

Everytime i want to make my code cleaner and simplier, I go to WDS. Thanks Kyle!

Ответить