VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
Clean Code: SOLID - Beau teaches JavaScript

Clean Code: SOLID - Beau teaches JavaScript

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
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! http://codepen.io/beaucarnes/pen/gmowZd?editors=0010 Ryan McDermott-s original article: https://github.com/ryanmcdermott/clean-code-javascript Other resource on SOLID: http://thefullstack.xyz/solid-javascript/ Beau Carnes on
Date: 2022-03-14

Comments and reviews: 7


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.

reply

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).
reply

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
reply

I think I'd rather have the good way of doing things first, then the bad. I'm afraid my brain will somehow stick with the bad just cause it was explained first. Scumbag brain
reply

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.
reply

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

At 6:30 you say that Im able to substitute squares and rectangles? How is it possible if square no longer extends rectangle?
reply
Add a review, comment






Other channel videos