Thank you! I feel I have grown a ton since I just started about a year and a half ago.
@TF23DayRespawn4 жыл бұрын
No kidding, everything from this channel screams 'quality'
@WebDevSimplified4 жыл бұрын
@@TF23DayRespawn Thank you so much!
@Bargains20xx3 жыл бұрын
totally agreed, he has a very good way of explaining stuff.
@igorrohlik3 жыл бұрын
could not agree more!
@covertgravy5 жыл бұрын
kyle: let me know if you wanna... me: yes
@thatoneuser86004 жыл бұрын
wut
@deansummer13564 жыл бұрын
@@thatoneuser8600 lul
@pahvalrehljkov4 жыл бұрын
i havent found any other source that explained so simply and concise, almost everything he explains here just clicks in my head... im enjoying watching his tutorials...
@alb123456725 жыл бұрын
This is so cool. I'm working on an app that makes 100s of API calls to different microservices. I have to show some sort of messagebox or alert in my axios catch if it fails or out of bounds.... I could have hardcoded a messagebox but now the client wants to log the messages and API them back to a server, so management can see them on a dashboard. Imagine having to add all those statements :lol:. I call an error function and can add a few lines of code now. We may want to move away from bootstrap dialogs, it would be really easy. You don't realize how important SOLID is until you need it! If you are duplicating any code consider making a function!
@ariassingh4622 жыл бұрын
Having classes with one method literally defeats the purpose of using a class. I feel like cohesion is more important than strictly adhering to the single responsibility principle. In this example the trackCalories and logCalorieSurplus are cohesive, so I don’t see a problem with keeping them in the same class
@SharukhSaifi4 ай бұрын
These are principles not laws.
@skewty4 жыл бұрын
A class with a single method is a code smell. The solution is typically a closure. Your example also exposed that log Message wasn't a good name for a function that sends an email. What happens as a result of exceeding calorie count is intimate knowledge and none of the class' business. Use an event or signal. I like your videos. Thanks for your work.
@jasonwelsh4174 жыл бұрын
This is such a great channel. I will be spreading the word as much as I can. Thanks for all the amazing content. I am only two years into my dev career and stuff like this is helping me think about how I code better.
@tomaskot92782 жыл бұрын
The final class still accumulates trajectories and keeps track of the value, compares it with a limit and logs a warning. All what changed is that it does not call the system log function, but does it indirectly through a custom function (which is a good change, but not sufficient if you really want the SR rule).
@alexboisseau617011 ай бұрын
Is that create a "Notifier" interface with a method "notify" could add more respect for the SR ? The CalorieTracker could take a third argument in his constructor (maxCal: number, notifier: Notifier, currentCal = 0) and during the instantiation of the class, pass a class which implement the Notifier interface (eg: LogNotifier)?
@leokr48773 жыл бұрын
In this case, I actually think that the new code is harder to read and maintain, because one function (track calories) suddenly does two things: Tracking AND notifying.
@umeshhbhat Жыл бұрын
Yeah that is what I was thinking. There should have been a separate function which checks whether calories have been exceeded or not.
@kerveybrillante82105 жыл бұрын
Please make more video about SOLID Principle. You're tutorials is always a big help. I have learn a lot. Thank you
@brianjlevine5 жыл бұрын
I think that this might be a little clearer if you explained the difference between having more than one method in a class and having more than one responsibility in a class. Helpful video, though.
@ellsonmendesYT3 жыл бұрын
I was wondering the same thing, but I think the classes is suposed to have one main function/method/responsibility whatever and maybe other helper methods
@aryalaashaya3 жыл бұрын
@@ellsonmendesYT hmmm interesting 🤔 never thought about it that way
@geo24655 жыл бұрын
thanks for the video! and please yes cover all the SOLID priciples.
@kelvezu15855 жыл бұрын
These are things that they don't teach in other tutorials. Thanks Kyle for sharing this solid design principle.
@PP-ss3zf5 жыл бұрын
Please cover the other letters for sure! Very useful to split them up and not give too much info.. thanks!
@Userkazt2 жыл бұрын
is this mean a class should only have single method ? eg: for a Cart class Add and Remove method should be in two separate classes ?
@wioetuw9123 жыл бұрын
But how do you decide what is a "single responsibility" or "one reason to change"? For example, you could argue that the CalorieTracker class is still responsible for at least two things: handling the tracking and defining what message to log in case the tracked calories exceed max calories. And you can take the argument even further. If a class and a method both need to satisfy the single responsibility principle, then how can a class ever have more than one method? Two different methods represent two different responsibilities so if they are both in the same class, the class must have at least two different responsibilities. Sure, the responsibilities of the class and the methods are on different levels of abstraction but then how do you know what is the correct way to split the program into layers of abstraction? I mean, otherwise I could just put everything into a function called runProgram and claim that the function satisfies the single responsibility principle because its only responsibility is running the program and it only ever needs to change if I wan't to change how the program works. I know that at least part of the answer to these questions is that you just have to use common sense. But the (supposed) usefulness of having an explicitly stated "single responsibility principle" is itself a consequence of the fact that it's very difficult to make correct decisions based on "common sense" unless you are very experienced in whatever you are doing. So I think it would be nice if there was more guidance on how to actually use this and other similar principles in practice.
@fayziyev3 жыл бұрын
Agree, if logic as well as the maxCalories should not be the part of the CalorieTracker. The maxCalories is used to decide whether to log or not to log a message, hence it is not part of the CalorieTracker. The CalorieTracker should only have a single property currentCalories, which might be passed to some logger instance or function, which implements an internal logic such as 'if (currentCalories > maxCalories) {// log something}'
@cotixmol2 жыл бұрын
Does this imply that a class can only have one method? It doesn't sound right.
@leandroroberto4433 жыл бұрын
Very well explained !!!
@clipsbyczar2 жыл бұрын
you literally have a video for eveything! Thank you so much!
@someonemight2 жыл бұрын
Good explanation. However, IMO to really separate responsibilities, CalorieTracker should call a notifyCaloriesExceeded function and that function would contain the message to output/email.
@HenleyBailey5 жыл бұрын
Thanks for all your tutorials, really well explained. Your human API is strong. :)
@armaandhanji71515 жыл бұрын
Thanks so much...please cover ALL the solid principles. Your explanation is amazing
@vitiok785 жыл бұрын
You are doing a very good job, Kyle! I understand your explanations better than others, although English is not my native language ))))
@MyTal1232 жыл бұрын
@web dev simplified Hi Kyle, on minute ~3:20 you say that in general we will use more modules than classes, can you please elaborate on that?
@bishopshawiii72925 жыл бұрын
Keep going with the SOLID principles. Awesome content. Thank you
@rebelmachine885 жыл бұрын
Great explanation! Would love to see more SOLID principles.
@WebDevSimplified5 жыл бұрын
Thanks! I am excited to make the rest of them.
@m126525 жыл бұрын
Great video as usual. The SRP can be a bit of a pain though if taken too far. As well as generating more code (in principal) it can lead to overly fragmented code. Personally, I find it’s more practical to think of a responsibility as a “manageable unit”. I.e. group the code in a way which is easily understood, easily maintained, only depends on generic methods and of course is DRY.
@this.channel3 жыл бұрын
Finally! I understand the S in SOLID. Now for the rest of the acronym :P
@mohammedalmukhtar89495 жыл бұрын
As always, thank you a ton, Kyle! You're an awesome instructor.
@albud66875 жыл бұрын
Great intro to SRP - and one of the simplest, most obvious examples there, to answer the question 'why separate concerns' with a recognizable use-case. I do think though, in today's post-SOLID world (OK Solid is still super relevant), you would do us a great service to warn of the evils of overseparation. For example, m12652 hints at this in the comment. "The SRP can be a bit of a pain though if taken too far. As well as generating more code (in principal) it can lead to overly fragmented code..." and then Víctor Navarro flat-out commits the error of overseparation when he comments "A question arise from watching the video: Isn't the CalorieTracker still responsible for logging the surplus? ... (see his comment)". It seems like common sense not to make that mistake, but well meaning people just take it to the other extreme. And you end up with multiple objects doing one thing. In Truth, the SRP is a sweet spot between OverCoupling and OverSeparation called 'Cohesion'. OverSeparating can kill as much as putting things in one huge method if you take it to the extremes. Read on .... Bob Martin, the guru who's evangelizing SOLID, recognized the problem in 2015 with this blog post: blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html Entire thing is worth a read. Here are some salient quotes: "The Single Responsibility Principle (SRP) states that each software module should have one and only one reason to change. This sounds good, and seems to align with Parnas’ formulation. However it begs the question: What defines a reason to change? .... "Another wording for the Single Responsibility Principle is: Gather together the things that change for the same reasons. Separate those things that change for different reasons. .... "as you think about this principle, remember that the reasons for change are people."
@baatar4 жыл бұрын
I think it might be worth it for Kyle to make a followup video encompassing these points.
@ikemkrueger2 жыл бұрын
That's why we have microservices.
@alvoradaprofética3 жыл бұрын
Your English is perfect thanks from Brazil 👏
@daninmanchester2 жыл бұрын
Should you not inject your logger, or maybe even use events for looser coupling? Using an interface would allow you to inject a logger of any type and would be helpful for testing. If you are likely to have multiple events, then I would think raising a max calories event would be best as you could hook all manner of handlers to this.
@daminipurohit69164 жыл бұрын
By far the best channel for learning web things! Thank you
@oleksandrvorovchenko86745 жыл бұрын
Thanks. And yes, would be great to cover the other patterns.
@ragilburhanudinpamungkas95714 жыл бұрын
Wold you like to make an express tutorial with typescript that implement SOLID design pattern? Thank you.
@EmanuelCaesar4 жыл бұрын
This is the best solid explanation.... tired of other channels xD
@tajpouria5 жыл бұрын
Great job Kyle you should definitely make content about three others principles using multiple examples,, thanks again dude
@netherlabgames75114 жыл бұрын
Congratulations you explained something in 6 min that others can't in 1 hour
@Sina-hr9fv4 жыл бұрын
thank you very much Kyle. you produce great content for free. i really adore you. by the way, what is that settings.json doing there? how are you handling es6 module & cors without a server?
@vimtor5 жыл бұрын
Hey Kyle. Excellent video as always! A question arise from watching the video: Isn't the CalorieTracker still responsible for logging the surplus? I understand that it does not contain the function for logging itself but it contains the logic of when to print and what message to use. I imagine that in a real world scenario you will use some kind of event system and when notified a CalorieLogger (for lack of a better name) will notice and do whatever it wants to do. What do you think about this? It is worth the effort to think in these terms or you can simply view composition as a way to separate responsibility? Thanks!
@WebDevSimplified5 жыл бұрын
This is a great point. In most applications generally it is fine to have that type of logic in the calorie tracker class since the main thing you are abstracting is how the logging works. The only time I would worry about event based systems was if I wanted to completely decouple two systems by using events between them to communicate. This is generally only useful in specific situations in larger scale applications since it introduces a bunch of other complexity and indirection related to the event system.
@hanumantuttekar.83165 жыл бұрын
Thank you. Please cover other letters of SOLID Principle 🙏🙏👍
@labwax5 жыл бұрын
Yes, please cover the other letters too. I really like the example.
@WebDevSimplified5 жыл бұрын
Thanks. I will do.
@ThomasIkemann Жыл бұрын
Hi Kyle, stupid question. What if I have a class like Car that can drive, stop, turn etc. Would the single responsibility principle "force" me to create own classes for these methods? That does not make sense for me^^ All those methods like toString(), substring() etc. are gathered below the very same class String as well, or do I missunderstand something here? I get the main point though, that a method should have one single reason only, so that if something has to change, you only change one spot of the class instead of one big giant method.
@kerryd20605 жыл бұрын
My hosting expires on Jan 4th. I'll check out your hosting.
@dz280214062 жыл бұрын
Very good explanation... Well done mate.
@jamstawildman4 жыл бұрын
Hi Kyle. I've only recently discovered your channel. There are others covering similar topics but yours is the best! Super helpful stuff :)
@saroj_kumar5 жыл бұрын
Hey Kyle. One thing I noticed from these comments that, you responded every comment that says good about the videos. I am a big fan too. Instead I wanted, you must answer the comments that are facing issues/problems running these examples. #Thanks_if_you_consider_this_worth_replying
@WebDevSimplified5 жыл бұрын
I try to reply to comments asking for help or negative comments as well, but those comments take more time to formulate answers for and I cannot respond to as many.
@saroj_kumar5 жыл бұрын
@@WebDevSimplified Now I got it! ☺️. One question from my side. I tried to import that function as u said in video, but it says Cannot import module outside the function. I am using npm live-server. Please answer if problem is in not using Node server or what else ?? 🤗
@saroj_kumar5 жыл бұрын
Anyone else knows the answer can reply.
@ulfdellbrugge4300 Жыл бұрын
I think it could be improved if the message was just returned or if the message function was dependency injected?
@mohsinalisep4 жыл бұрын
You did a smooth job explaining it!
@stith_pragya Жыл бұрын
Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@imranhaider43165 жыл бұрын
Thanks Kyle for making so complex things easy for us.
@Shubham-xh9nz4 жыл бұрын
Im glad that i found your channel
@Shubham-xh9nz4 жыл бұрын
keep posting
@A_Lesser_Man4 жыл бұрын
I've been doing this, mostly. I'm glad I now know a name for the idea. Time to start combing through all 30,000+ lines of code. Eek.
@petertester9155 жыл бұрын
DAS IST GUT!!! More solid please!!
@olyalitvinova9213 Жыл бұрын
Hey! does it mean that class better have no more than 1 method?
@edwardtam14565 жыл бұрын
This looks good. I think there could be better choice for the example though, because console logging is kind of generic and all over the place that usually people treat it as part of everything.
@ZaidIrfanKhan4 жыл бұрын
Hello, I am getting an error: Cannot use import statement outside a module. I guess it's something to do with the settings.json file. What changes would I need to make in that file, in order to make this work in VS code console? Any help would be appreciated
@copyfx003 жыл бұрын
I'm guessing you already solved it, but if someone got this problem, i fix it by adding: type="module" in the script tag of the Html, so now it is: ps: this only work using live-server
@ZaidIrfanKhan3 жыл бұрын
@@copyfx00 yup that's how I solved it, thanks for the reply
@cinammondream2 жыл бұрын
This is great, thank you!! Amazing video!
@jjnimes4 жыл бұрын
Very helpful and well explained! Auto subscribed haha
@julienwickramatunga73384 жыл бұрын
Nicely explained!
@ritwizsinha12614 жыл бұрын
You certainly simplified the web for me
@דורשמואל-ס6ט4 жыл бұрын
You explain so good man
@AslamD4 жыл бұрын
very helpful video. can we also call this microservice ? or is it different?
@zymzym24554 жыл бұрын
Can you please share how do you get your code to auto run in the in the Chrome dev console? Thanks
@danilopaulinodasilva4 жыл бұрын
This is not possible in the "simple" way he show in video. Is not simple as "Click with right click on the mouse and open JS with browser LOL". Here what I do to get this done: 1. Created a file index.html 2. Put the inside this file 3. Open it with Live Server plug-in inside the Visual Studio Code Important: Without the type="module" recent browsers will not understand the import in the code!
@НиколайТодоров-и9т2 жыл бұрын
Very concise and up to the point, bravo!
@reelstrendingsongs4 жыл бұрын
1000 subs/day ( wow congrats )
@nicbongo4 жыл бұрын
How would you apply this principal when working with fetch requests and state?
@suryapratapsingh51495 жыл бұрын
Super cool and simple way ... God bless you.
@Indrajeetviper5 жыл бұрын
Just one thing, why don't you use semi colons at EOS?
@learnbit_bo3 жыл бұрын
clear explanation thank you
@pastorfred25435 жыл бұрын
Great Tutorial.. My Hero Always On Point. Thanks Sir.
@saradamala76524 жыл бұрын
Which is the best class or composition function?
@Horoe5 жыл бұрын
Uncaught SyntaxError: Cannot use import statement outside a module
@tannerdolby13614 жыл бұрын
This is because your tag is not expecting you to import a module with Update it:
@uzairsaqib92983 жыл бұрын
You are great man !!!
@arinmovsesian Жыл бұрын
prefect explanation
@vnm_89453 жыл бұрын
I want to ask a simple question I just noticed. What's the difference between a function written using the "function" keyword as "function example() {}" and writing it as "example() {}"? Thank you.
@hehimselfishim Жыл бұрын
been two years and i bet youre probably a senior dev by now but if not adding the "function" keyword is using when youre declaring the function, then using it the other way is when its in classes or when youre calling the function.
@RodrigoButta5 жыл бұрын
Thank you!!! It's nice to refresh all this kind of good practices.
@dmytrodanko85922 жыл бұрын
ok but it is brake another SOLID principle that said - do not change if it made (open/close principle, you can't change some method if it in use)
@usama579265 жыл бұрын
what is expert default function.....❓❓❓❓
@WebDevSimplified5 жыл бұрын
It is ES6 modules. I have a video on modules you can checkout on my channel for an in depth explanation.
@RN-ru2rj4 жыл бұрын
Awesome 👍. Thanks a ton!
@ajithvencode9164 жыл бұрын
awesome man..keep going
@srinivasgangaraju2998 Жыл бұрын
video starts @ 1:26
@noice1006 Жыл бұрын
Thank you
@Abhishekkumar-vf8qe5 жыл бұрын
Thanks for such a great videos
@redye58585 жыл бұрын
love your tuts man
@shamilmammadov82465 жыл бұрын
Please cover other principles with such simple example
@vossert3 жыл бұрын
Hi Kyle, Thank you so much for all the effort you put into this channel. You taught me so much already! I prefer hands-on learning so I code along with all your videos. What is your VSC setup so you can run the js and see the output on the right side in developer tools / console? Is it a new node project every time?
@bryceblazegamingyt9741 Жыл бұрын
I think he's loading an html document in his browser and using that as a test-bench.
@InvincibleMan994 жыл бұрын
Would you mind if you can share code ?
@utkarshdixit72353 жыл бұрын
Just confused as to why are you not using the sponsor's service for your own website server, if it's more powerful than your current hosting service, on top of 1-year free hosting. I smell something fishy xD Great video btw
@someone-gp8fm3 жыл бұрын
Now what about the part where you're checking if the current calories is greater or equal to max calories, shouldn't this get handled by another class too? Because now you are doing to things adding the calories and validating the value, also sometimes having a single class to do a very small task seems to be overkill, what about having other methods in the class and each method takes a single responsibility?
@ahmedboutaraa87714 жыл бұрын
great as allways
@CommunityAllSeasons5 жыл бұрын
This is amazing content!
@michaborski73833 жыл бұрын
thank you !
@Michael89312 Жыл бұрын
very good. cheers
@dangnguyen.925 жыл бұрын
yes, pls do the rest principles
@Atif17024 жыл бұрын
Video starts at 1:26
@michaelNguyen9145 жыл бұрын
Amazing channel
@samueltorres24853 жыл бұрын
Just found this channel. Great content, you teach these complex concepts well.