SOLID Design Principles Explained in a Nutshell

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 131

  • @ADevStory
    @ADevStory  5 місяців тому

    Hey folks!👋 Want to have hands-on practice on these concepts? 🤓
    Try out CodeCrafters.io we have partnered and you can get 40% off 💸with this link: app.codecrafters.io/join?via=DevStory
    They have great hands-on tutorials and easy to get up to speed with complex systems. Check them out!

  • @NaumRusomarov
    @NaumRusomarov 3 роки тому +44

    I picked this video to watch not because it's the best, I don't know that, but because it's short. :-)

    • @ADevStory
      @ADevStory  3 роки тому +6

      Nice! Yeah I'm trying to make them fairly short, though I keep failing to make them < 5 minutes AND useful :)

    • @johnnyxp64
      @johnnyxp64 2 роки тому

      And because is not another annoying Indian accent that makes your brain omelette, so instead of focusing to understand the point you try to slow down the fast bad English accent of the presenter and you are missing the point.

    • @jacktilley7299
      @jacktilley7299 2 роки тому

      Yes. Too many lectures in this industry

    • @ganybaba9377
      @ganybaba9377 Рік тому

      ​@@johnnyxp64 lol. Loser.

  • @demontime4192
    @demontime4192 2 роки тому +2

    I was trying to find a starting point to digest all this information but kept running into content that over explained and brought in new terms without context. Your vid was the perfect place to begin understanding these new concepts. Great examples and explanations without going too high level. Thank you!

    • @ADevStory
      @ADevStory  2 роки тому

      Glad you enjoyed it and thanks for the feedback! Any other topic that you may want to learn about?

  • @persiansayed
    @persiansayed 2 роки тому +16

    I have an interview tomorrow, and I just wanted to quickly revise some of the common topics. This is one of the best video I have found to understand SOLID principles. Thank you for this clear and concise video. 👍

    • @ADevStory
      @ADevStory  2 роки тому +1

      Thank you for the feedback! Glad it was useful and good luck in the interview!

    • @kisan-majdoorkalyansamiti7390
      @kisan-majdoorkalyansamiti7390 Рік тому

      Lot of novice interviewer always ask methodology name rather than saying about challenges and asking solution .
      Always ask tell in your challenges and then I give solutions then 90% interviewer has no answer 😂😂😂

  • @davepascual39
    @davepascual39 Рік тому +2

    This is a great and short on how SOLID principles works. It really helps me understand the basic of it .

    • @ADevStory
      @ADevStory  Рік тому +1

      Thanks! Glad it was useful!

  •  2 роки тому +10

    I would separate the vehicle into automatic vs manual, because there are also automatic combustion vehicles.
    Electric cars have a gear box similar to automatic cars, but specialized.
    Otherwise, great and concise explanation of the principles :)
    I had difficulty with understanding the liskov principle, but you've explained it well and now I get it.

  • @faithyintii8457
    @faithyintii8457 2 роки тому +1

    Wow, I just understood all this under 7 mins , thanks kind Sir.

    • @ADevStory
      @ADevStory  2 роки тому

      Nice! Glad it was useful!

  • @ivaXP
    @ivaXP 3 роки тому +18

    This was short and very easy to understand with the practical examples. Thanks!

    • @ADevStory
      @ADevStory  3 роки тому +1

      Glad you enjoyed it!

  • @david_ramoraswi1711
    @david_ramoraswi1711 3 роки тому +7

    preparing for an interview and you made this concept way easier for me,thanks

    • @ADevStory
      @ADevStory  3 роки тому +1

      Glad it was useful! That was part of my idea originally. You can check the playlist for other topics that are common in technical interviews.
      And BTW good luck in your interview!

  • @alexhandzhiev
    @alexhandzhiev 2 роки тому +1

    Thank you!!1 I have like 11-12 years of experience but just now I actually understood what SOLID means! Thanks again :D

    • @ADevStory
      @ADevStory  2 роки тому +1

      Amazing! Glad it was useful!

  • @stevestorniolo257
    @stevestorniolo257 3 роки тому +2

    Awesome video for when I need to remind myself of these principles.

    • @ADevStory
      @ADevStory  3 роки тому

      Glad it is useful for you!

  • @TheLovableRascal
    @TheLovableRascal Рік тому +1

    A good, brief summary, thank you for taking the time to make the video 🙌

    • @ADevStory
      @ADevStory  Рік тому

      Thanks! Glad you liked it!

  • @gabrielbott4659
    @gabrielbott4659 Рік тому +1

    Wow thank you for this wonderful, im beginner teaching myself it very hard to find clear and concise materials on OOP. ;-)

  • @jamestill4172
    @jamestill4172 Рік тому +1

    SOLID programming means abstracting your code, having classes depend on abstractions (like interfaces), and not other classes. The best code is simple and de-coupled, easy to modify without breaking everything, and easy to read.
    Single responsibility: Each class should have a single responsibility.
    Open/closed: Classes should be built to extend and be closed for modification.
    Liskov substitution: Changing instances with sub-types shouldn't break your code.
    Interface segregation: Delegate functionality to interface classes. Too many interfaces > too few.
    Dependency inversion: High-level classes should rely on abstractions (like interfaces) rather than on lower-level classes. You're inverting their dependency.

  • @harsh9558
    @harsh9558 4 місяці тому +1

    Great explanation,🔥

    • @ADevStory
      @ADevStory  4 місяці тому

      Thanks you! Glad you liked it!

  • @markrankin4078
    @markrankin4078 3 роки тому +1

    Good video, best and most concise I've seen

  • @chrisdietrich1533
    @chrisdietrich1533 4 місяці тому +1

    Great explanation thank you

    • @ADevStory
      @ADevStory  4 місяці тому

      Thank you! Glad you enjoyed it!

  • @silkogelman
    @silkogelman 2 роки тому +2

    Very clear and to the point, thank you Christian! 🙏
    The examples with the diagrams really made it clear, going to apply these in Python.
    Love to see more about these principles and design patterns.
    Liked and subscribed ✅

    • @ADevStory
      @ADevStory  2 роки тому +1

      Oh so nice it was useful for you. Will make a few more on design patterns. Thanks!

    • @silkogelman
      @silkogelman 2 роки тому +1

      @@ADevStory🥳I'm looking forward to them, thanks! 😀

  • @CS-eh8eo
    @CS-eh8eo 3 роки тому +3

    I don't think I understand what open closed principle REALLY means... Like how can a class be closed for modification? I think it's talking about using immutable objects and stateless classes, because it's the state of the class that can change. Open for extension on the other hand is saying you should use interfaces to swap out implementations, I don't think using inheritance is a good idea because you're tied to that base class, especially if the class is part of an Api. Basically you should program to interfaces so your implementations can be swapped out for different ones and your existing code doesn't change, new code is added. This is what open closed principle really means. What do you think?

    • @ADevStory
      @ADevStory  3 роки тому +4

      Yeah the principles can be confusing. And the specific naming of the open/closed one it's tricky.
      I'd say the main idea is that in case you need to add behavior to a program/class, instead of adding the behavior to the class, make it easier to replace or extend the behavior of it. Not necessarily with inheritance I'd say.
      Here's an article that I think explains it very well. medium.com/@alexandre.malavasi/why-is-the-open-closed-principle-so-important-bed2f2a0d4c7
      Let me know if it helped :)

  • @ruudiluca
    @ruudiluca Рік тому +1

    Thank you! This has been useful.

    • @ADevStory
      @ADevStory  Рік тому

      Awesome! Thank you! Glad you liked it!

  • @vabav007
    @vabav007 2 роки тому +1

    Really well put. Thanks a lot for this.

    • @ADevStory
      @ADevStory  2 роки тому

      Thank you! Glad you liked it!

  • @florianvanbondoc3539
    @florianvanbondoc3539 Рік тому +1

    Thank you, I really like the fact that this video was kept small.

  • @bonnoManus
    @bonnoManus 3 роки тому +1

    Topic was nice....but your explanation was not very clear. I appreciate you tried to explain this hard topic in a concise manner.

    • @ADevStory
      @ADevStory  3 роки тому

      Thanks for your feedback! What can I do to make it clearer in the future?

  • @sebon11
    @sebon11 3 роки тому +1

    Great explanation, clear examples :)

    • @ADevStory
      @ADevStory  3 роки тому

      Thanks! Glad you enjoyed it!

  • @ReporterTorizo
    @ReporterTorizo 3 роки тому +2

    The examples threw me off COMPLETELY because I didn't know that electric cars don't have transmissions.

    • @ADevStory
      @ADevStory  3 роки тому +1

      Sorry for that. On the bright side you now know about cars and object orientation 😅

  • @CloudGamingTheOriginal
    @CloudGamingTheOriginal 4 роки тому +1

    Great summary bud!

    • @ADevStory
      @ADevStory  4 роки тому +1

      Thank you very much!

  • @prathieshnavekneswaran2746
    @prathieshnavekneswaran2746 2 роки тому +1

    Thank You! Helped a lot!

  •  4 роки тому +1

    Great video! Congrats, keep rocking!

  • @pointer333
    @pointer333 Рік тому +1

    another banger! thanks again!

  • @AllanJeremy
    @AllanJeremy 3 роки тому +1

    Subbed. Succinct and perfect refresher!

  • @nishiths9228
    @nishiths9228 3 роки тому +1

    Hi there , I really like these videos as it one of the best videos which explains about lot of important concepts required to be better dev and which is not found in the sea of UA-cam videos … I would also like to know if there are any books that you would recommend for becoming a advanced java programmer starting from the basics ..
    you may recommend like for beginner this is best and after that this book is best …
    Thanks in advance ! Appreciate your hard work in creating such a quality contents with loads of essential stuffs in them for being a good and better dev … love your videos ! 💕

    • @ADevStory
      @ADevStory  3 роки тому

      Oh thanks for the compliments 😀 regarding books on design patterns check out the description. Regarding java beginner java books I would recommend (though I haven't read) Head First Java , and Effective Java (this for all levels and it's quite nice).

  • @bariswheel
    @bariswheel 3 роки тому +1

    Good stuff, thanks for posting.

    • @ADevStory
      @ADevStory  3 роки тому

      Thank you for watching! If you feel it can be useful to someone else please share and also if you want me to cover other topics, let me know :)

  • @josemtz6430
    @josemtz6430 3 роки тому +2

    great explanation, thanks!!!

  • @frankhernandez4057
    @frankhernandez4057 2 роки тому +1

    Applying the Interface principle 4:43 wouldn’t this break the Leskov principle because you can replace vehicle with combustion since it has another method not used?

    • @ADevStory
      @ADevStory  2 роки тому

      Nope, because you are specializing the classes. That's perfectly ok. What is not ok (according to Liskov) is if Vehicle has methods that can't be implemented by either Electric or Combustion (for example, shift() method). Hope is clearer :)

  • @JustinK0
    @JustinK0 2 роки тому

    1:40 seems like a good way to use a façade pattern, the engine class can be the top level class with the other subclasses underneath,

    • @ADevStory
      @ADevStory  2 роки тому

      I'm not sure I follow what you mean. At that time I'm talking about vehicle, engine and tire. Engine can't be a façade for those two 🤔

  • @TheAlexanderpietsch
    @TheAlexanderpietsch 4 місяці тому

    I wonder on min 5:11 where there is an composition drawn between Vehicle and Tire, shouldn't the owning (filled diamond) be on the Vehicle side?

  • @yehuda4904
    @yehuda4904 3 роки тому +1

    Wow, thank you so much for sharing the information... Very clear :)

  • @tulikagupta5009
    @tulikagupta5009 3 роки тому +2

    Great content and easy to follow. Can you also make videos on gang of 4 creation design patterns?

    • @ADevStory
      @ADevStory  3 роки тому +1

      I did already :) ua-cam.com/video/aiSAO2AXa9g/v-deo.html

    • @tulikagupta5009
      @tulikagupta5009 3 роки тому +1

      @@ADevStory I saw those also. Very easy to understand. Never knew so many benefits of builder pattern.

    • @ADevStory
      @ADevStory  3 роки тому

      Glad you enjoyed them!

  • @mitrabest9756
    @mitrabest9756 2 роки тому

    Good keep going 👍

  • @rafadydkiemmacha7543
    @rafadydkiemmacha7543 3 роки тому

    It's always so easy with those examples like Cars and Animals, but then in real life projects those principles are extremely hard to use. And almost nobody does, at least in huge projects.

    • @ADevStory
      @ADevStory  3 роки тому +1

      In my experience they are used extensively in any maintainable project. The thing is that it depends a lot on the domain so the examples would be way more specific in that sense. But factories, singletons, decorators, adapters, proxies, and observers are probably some of the most used ones.

  • @quinnyboym6282
    @quinnyboym6282 2 роки тому +1

    On 5:13 these open arrows mean "is-a" right? But then it says on the bottom a Bike is a Tire and a Car is a Tire, what am I seeing wrong here? Thanks for the helpful video tho, just don't understand this last thing. Exam tomorrow... ahaha

    • @ADevStory
      @ADevStory  2 роки тому +1

      Yeah the arrows mean "is-a" and sadly by being lazy the diagram is wrong: I meant a "BikeTire" and a "CarTire" are both tires

  • @kevingreetham4175
    @kevingreetham4175 9 місяців тому

    What I’ve never been able to understand tho is how do we know what engine and tyre refers to what car though if they are not stored within the same class? Do I have a common id between classes or should I store the engine and tyre classes as properties of the specific instantiated car object and provide methods from the car object which target thr internal class ?

    • @ADevStory
      @ADevStory  9 місяців тому

      It depends, if your class relies directly on a specific behavior of an implementation then you need to include that one. For example: A Toyota Camry requires engine X. But sometimes you might even generalize it and say: a Toyota Camry has an engine.
      The constructor for ToyotaCamryCass only needs to recieve an object of type "engine" and doesn't care which specific engine it is.

    • @ADevStory
      @ADevStory  9 місяців тому

      Hope it makes sense

  • @edymbhify
    @edymbhify 3 роки тому +1

    Fantastic explanation, just missing code examples, on git.

    • @ADevStory
      @ADevStory  3 роки тому

      I can create some and paste them later. I'm intentionally trying not to show code in my videos, and focus more on the concepts.

  • @kisan-majdoorkalyansamiti7390
    @kisan-majdoorkalyansamiti7390 Рік тому +2

    Lot of researcher to show they given new concept it is biggest stupidity.
    Main thing is missing what are problems and to solve what are possible solution then we can say this methodology solve this way .
    Lot of novice interviewer always ask methodology name rather than saying about challenges and asking solution .

  • @poojaguru2516
    @poojaguru2516 3 роки тому +1

    Good one!

  • @alialwerfally6497
    @alialwerfally6497 3 роки тому +1

    thank you so much

  • @zeekcom12
    @zeekcom12 3 роки тому +1

    Thank you!!!!!

    • @ADevStory
      @ADevStory  3 роки тому

      You're welcome! (With Maui's voice) 😁

  • @Name-lt2tz
    @Name-lt2tz 3 роки тому +1

    what I hate when coding and there are injected interfaces, it is hard to find which class will be injected when interface is implemented by few classes. I have to debug then - not readable code, I cannot tell just by looking at the code. I see good programmers not using interfaces everywhere so this makes me doubt readlly that this is useful thing to do.

    • @ADevStory
      @ADevStory  3 роки тому

      It depends. Using interfaces allows for better code decoupling, easier testability and better maintenance. Having said that, in many cases you end up with code that depends on interfaces where there will "always" be only one implementation, or that it isn't expected to change "almost ever" (i.e. you don't expect a dependency injection framework to dynamically inject other dependencies, don't expect polimorphism). This, tied with the capacity of more recent testing frameworks like Mockito that allows to mock concrete classes, doesn't require to have explicit interfaces.
      Code complexity by having interfaces shouldn't be greater either, and most modern IDEs (if not all) allow to easily navigate through the interfaces and specific implementations.

    • @Name-lt2tz
      @Name-lt2tz 3 роки тому

      @@ADevStory at least PHP storm - if I click on dependency which is injected using intereface, it moves me to interface. And then can navigate to classes implementing the intereface. Ide suggests those classes but it does not know which one is being injected. So I only can find by debugging.

    • @ADevStory
      @ADevStory  3 роки тому

      Oh I see. I think in that case it's more about how easy is to understand the framework dependency injection configuration than about using interfaces.

  • @Name-lt2tz
    @Name-lt2tz 3 роки тому

    open closed principle - I have seen such in codebase when there is abstaract class and you have to implement methods. But I do not see its benefit. I have needed for example add parameter to the method of child class. So I have to add parameter to parent class so the method definition would be same. At least in php, otherwise you get error. But this parameter is not needed for other child classes, so solution is to have unused parameters in function. Now I think another solution could be to pass some objects implementing some interface and they could have one interface but completely different amount of parameters.

    • @ADevStory
      @ADevStory  3 роки тому

      Yeah you are right :) and that's great that you have experienced this. There are different things to take here:
      - Code is not supposed to be static. It will change overtime. If you notice part of the code that is always changing while other parts are always static, then that dynamic part is candidate for extraction (like you said, with interfaces). So the Open/Closed principle is not so much about "writing once and not touching ever" as it is more about keeping the things that don't change or are common in one place while allowing for extending that behavior elsewhere.
      - IMO SOLID principles shouldn't be seen in isolation from one another. In this case Open/Close Principle relates a lot with others like Single Responsibility principle. If a class has it's responsibility well defined and is implemented according to that, any extension to the responsibility elsewhere should be done outside that class. And of course, if the responsibility of your class changes (requires new params, calculations changes, etc) then the responsibility of your class must change accordingly.
      Hope it's clearer :)

  • @georgedulica2925
    @georgedulica2925 Рік тому

    Dependency inversion seems to be similary with interface segregation

    • @ADevStory
      @ADevStory  Рік тому

      They all relate but are different :)

  • @carlosalarcon2737
    @carlosalarcon2737 3 роки тому +1

    Thanks

  • @pointyneedle7837
    @pointyneedle7837 3 роки тому +1

    Nice , please add subtitles

  • @lilenoulitza
    @lilenoulitza 3 роки тому +9

    I lost everything after the Single responsibility :p lol i must be so stupid

    • @ADevStory
      @ADevStory  3 роки тому +1

      What did you miss? Is it clearer now?

    • @yehuda4904
      @yehuda4904 3 роки тому +3

      Yes, these are hard concepts that takes years to understand... Unfortunatly, it can be understood with experience or some one explainning it face to face...

    • @anuragyada7379
      @anuragyada7379 Рік тому

      @@ADevStory oooooo9oooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooo

  • @raphaelmacsa1992
    @raphaelmacsa1992 3 роки тому +2

    3:01 Java code inside Visual Studio... LMAO 🤣

  • @Name-lt2tz
    @Name-lt2tz 3 роки тому +1

    why single responsiblity is not called like high cohesion principle instead? that would be real name, because single is a lie then, at least from what I see people doing.

    • @ADevStory
      @ADevStory  3 роки тому

      Well is not only about cohesion but actual responsibility. If I understand your point correctly in this case a "single responsibility" is a subset of "high cohesion". You could have high cohesion with multiple responsibilities and that's not the purpose of the principle.

    • @Name-lt2tz
      @Name-lt2tz 3 роки тому

      @@ADevStory but I never practically see single responsibility. For exmaple most controllers have methods like this: create, update, delete, list. How this is single? 1 create, 2 update, 3 delete, 4 list. For responsibilities.

    • @ADevStory
      @ADevStory  3 роки тому

      That part gets philosophical sometimes. You could split each of those operations in different classes too. The important thing is to have the responsibility clearly scoped. For example, if it's UserController: responsible for handling user registration.

  • @YoungDev98
    @YoungDev98 3 роки тому +1

    gj bro, thanks

  • @YusufxonToshkandiy
    @YusufxonToshkandiy 3 роки тому +1

    TOO BAD

  • @aleksanderm1947
    @aleksanderm1947 2 роки тому

    Bro, buy a good mic.

    • @ADevStory
      @ADevStory  2 роки тому

      I did! Checkout my newer videos :)

  • @davyboi2469
    @davyboi2469 2 роки тому

    I hate studying for this boring as programming crap

  • @funnyteja8181
    @funnyteja8181 Рік тому

    Maa

  • @CASLOAcademy
    @CASLOAcademy 2 роки тому

    weird

  • @av733
    @av733 2 роки тому

    can't understand your accent

    • @ADevStory
      @ADevStory  2 роки тому

      Sorry about that. Did you try the English subtitles?

  • @ochoax2628
    @ochoax2628 Рік тому

    So sorry but your explanation is not clear. I can read powerPoint presentations as well. The examples given in this video are not useful. Keep improving.

    • @ADevStory
      @ADevStory  Рік тому

      Sorry to hear that. How would it be more useful?