Clean Code: SOLID - Beau teaches JavaScript

preview_player
Показать описание
Learn the best practices of how to write clean code in JS. This video tutorial is over the S.O.L.I.D. principles of clean code programming:
S – Single Responsibility Principle
O – Open-Closed Principle
L – Liskov Substitution Principle
I – Interface Segregation Principle
D – Dependency Inversion Principle

Learn what these mean and how to implement them in JavaScript!

⭐JavaScript Playlists⭐

-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Рекомендации по теме
Комментарии
Автор

Sorry Beau, that's not a good example of Open/Closed. What if I want to add the ability to delete flavors? O/C is more about extending functionality, not data manipulation.

anthonyl
Автор

From what I understand, dependency injection is more about not having 'hidden' dependencies within the function that is being called, but rather explicitly state what dependencies are used. This helps with testability (mocking/stubbing). By injecting the dependency or class you can easily create an object that will give you the behavior or state that is being tested. In the example in the video, the function call is changed to determine the type of protocol used to perform the request. However, you still use different classes in the function that's being called without the ability to mock them and hence only test the actual logic behind your request. Another side benefit of injection is speed. Your tests will run faster if they have a 'canned' answer ready rather than use the actual service (implementation).

crazylegs
Автор

With "push" you are modify reference so "close" from close to be modified is not respected.

valikonen
Автор

There are few problems with this video.

First these are PRINCIPLES, not RULES. As such you can't label things as BAD and GOOD. More like BETTER and WORSE. Or RECOMMENDED and DISCOURAGED. There are always situations where you need to ignore some principles, or say stop, and know at which point to say stop to making everything to adhere to principles to every last details. The problem with following some of these principles, is that the code and setup on a caller side is bigger than in your "BAD" examples, as such it can be actually BAD. One of the examples would be cryptographic libraries. You often want to restrict extensibility or dependency injection abilities, because it makes it easier to mess things up leading to unsecure system. There are many other situations in general code.

Also, you can make Square be a child class of Rectangle, as long as you put only read only properties / actions into interface, and the modifiable ones into constructor. There are few other options that will still adhear to the L principle, without creation of Shape interface.

movaxh
Автор

Does good Open/Closed example violates SRP?

saisagarsharma
Автор

I feel like the good/bad examples of Single Responsibility are poorly represented here. I think it's legit for a class to implement more than one method, as long as the methods each have a single responsibility. I think it would be more illustrative of a real world problem if you start with a function that does both and break it up into functions that do each.

huzbum
Автор

You gave a bad example for the Liskov Sibstitution principle, the goal is to sibstitute the Parent class with child class but it needs to work on the reverse direction also, and it is not going to work

saharis
Автор

Uncle Bob said this representatiof square and rectangle is wrong in his video

bakaougg
Автор

O/C has two reasons to change. addflavor and makeIceCream

janmichaelbesinga
Автор

Strange only 33K views, it seems nobody wishes to write clean code and instead prefer "Spaghetti"

Vikram
Автор

No man , examples are not to the point and technically incorrect.It is old video but should have replace this with the better one.

Hungrymind
Автор

Good abstraction :) thankssss!!!! a lot

MarcusPianco
Автор

Class? For a Javascript lessons? Seriously? That's extremely bad.

DroneTonSoukhoï...etPafLeMig
Автор

SOLID seems like an antipattern. Lol is this just super old fashioned? if you did this you would end up with thousands of classes.

boot-strapper
join shbcf.ru