Dependency injection fundamentals in C# - DI vs IoC vs DIP

Поділитися
Вставка
  • Опубліковано 5 лют 2025
  • In today's video we're going to cover Dependency Injection fundamentals.
    We'll cover Dependency Injection (DI), the Dependency Inversion Principle (DIP), Inversion of Control (IoC, IoC container). We'll talk about what each of these are, what the difference between them is, and how we can apply these principals via an example and leveraging the Microsoft.Extensions.DependencyInjection nuget package.
    Connect with me on 'em socials:
    Twitter: / amantinband
    LinkedIn: / amantinband
    GitHub: github.com/ama...
    Check out all my courses on DomeTrain:
    dometrain.com/...
    Support the channel and get the source code:
    / amantinband
    Thanks for watching, don't forget to like & comment & subscribe! ❤️ 💻

КОМЕНТАРІ • 54

  • @tiffaleyshon1126
    @tiffaleyshon1126 11 місяців тому +45

    Dude! I'm a programmer of over 20 years and I've never seen it explained this clearly and concisely before.

    • @nick_stelmakh
      @nick_stelmakh 11 місяців тому +2

      agree

    • @joofville
      @joofville 10 місяців тому

      Agree and subscribed

    • @omersoncruz1081
      @omersoncruz1081 7 місяців тому

      Super agreed. Im loving this guy now. #Subscribed

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

      ME 3 Excellent Description.

  • @princearthur4868
    @princearthur4868 4 дні тому

    Thank you Amichai for the detailed explanation.

  • @learndevtech
    @learndevtech Місяць тому +1

    Magic video and very deep knowledge sharing! Can't recommend the courses enough!

  • @mohannadqa5101
    @mohannadqa5101 11 місяців тому +5

    5:06
    Man, finally it clicked. I'm so happy thank you.
    Dependency injection. Such a fancy word for an obvious concept.
    But now it makes sense, you are injecting a dependency rather than sticking with a specific dependency.

  • @IncompleteDeveloper
    @IncompleteDeveloper 2 місяці тому

    Very helpful that you distinguished DI, DIP and IoC container. Sometimes these are all lumped together, opening the door for confusion

  • @issamboutissante1542
    @issamboutissante1542 11 місяців тому +5

    This video is amazing
    Can’t wait for the next one.

  • @AK-vx4dy
    @AK-vx4dy 11 місяців тому +2

    Nice clear and practical take. Excellent job !

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

    Your content is great. I am following you since a year and I have learned alot. Surely gonna buy those courses.

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

    This is the best video explaining those concepts. Amazing, thank you.

  • @flavioboscarol1555
    @flavioboscarol1555 Місяць тому

    told slightly "fast" :) ...but well done and complete....thanks for the excellent explanation.

  • @BGivo
    @BGivo 11 місяців тому +2

    Love your recent videos. Thank you!

  • @shahzadahmad-vg2ou
    @shahzadahmad-vg2ou 11 місяців тому

    Bro, I was always confused between these terms, Thank you for this awesome video.

  • @kamilmikua5794
    @kamilmikua5794 10 місяців тому

    nice, we need more content like this, good job!

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

    Wow, I really needed this video, very clear explanation

  • @dhmilmile1
    @dhmilmile1 11 місяців тому +4

    Thanks for the great explanation.

  • @adamsontag1874
    @adamsontag1874 11 місяців тому +1

    Thank you for very nice and clean explanation.
    I have a few questions:
    1. As you need Service provider to be built, does that mean that you can register services only on startup of the application or is there a technique to safely register services during runtime ?
    2. Let's say I have DbContext from entity framework and I have two databases meaning they have two different connection strings. Is there a way to use EF with dependency injection in a way that would be able to resolve the correct database ?
    And again thank you for great explanation it was very helpful to me.

  • @FredericMerouze
    @FredericMerouze 11 місяців тому +1

    great explanation amichai, thank you :)

  • @itsgddemon7573
    @itsgddemon7573 11 місяців тому +1

    Could you consider making a video about what is the difference between making the validation inside the valueobjects, entities and with fluentValidation, could we mix and match these validations and what is the best approach.

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

    I could just say it's AMAZING

  • @davood7497
    @davood7497 10 місяців тому

    Clear and Concise !

  • @theanachronism5919
    @theanachronism5919 11 місяців тому +1

    Awesome! Maybe I ask what you use for drawing on the screen during the screen record?

  • @thijsvandervegt3377
    @thijsvandervegt3377 11 місяців тому +2

    Hey Amichai, have you ever thought about making videos about Modular Monoliths? Thanks for the video btw :)

  • @davidjiang7929
    @davidjiang7929 11 місяців тому

    Another great lesson!
    Would you please consider making more videos on c# core concepts needed for .NET? 😊

  • @margosdesarian
    @margosdesarian 11 місяців тому +4

    Hi Amichai, it would be great if you could slow down just a little bit - say 5%. Its a little hard to keep up at that speed :) OH dont worry, i discovered that you can run it at 75% speed., although you do sound as if you have had a few too many beers ...

    • @R3ap4r
      @R3ap4r 11 місяців тому +4

      Standard procedure for me, Tim Corey -> Set speed to 1.25x , Amichai -> Set speed 0.75x == Learning curve exponential :)

    • @dashaenne
      @dashaenne 11 місяців тому

      🤣

  • @oseifrimponggg
    @oseifrimponggg 3 місяці тому

    Hi everyone, not to be "that guy" but I am a beginner in c# learning concepts and trying to build projects and I'm totally lost here. What are the other concepts, I should learn before coming to this video? Of course, I know classes and basic OOP, but I need this video to make me smile and not question my potential in becoming a SE :)

  • @Luiz-yo2qf
    @Luiz-yo2qf 9 місяців тому

    Hi mate. Awesome video! thank you for the great explanation.

  • @mercyfulM30
    @mercyfulM30 7 місяців тому

    hey, first of all thank you for the video. maybe quite an newbie question but how do you generate the classes and method so fast? is it a shortcut/key or is it something like copilot? thank you very much!

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

    At around 3min would that not be Abstraction instead of encapsulation?

  • @Noone-bb5qh
    @Noone-bb5qh 11 місяців тому

    I can’t thank you enough 🙏🙏🙏

  • @greekplayback
    @greekplayback 11 місяців тому +1

    תודה אלוף ❤

  • @hasithadhananjaya2806
    @hasithadhananjaya2806 3 місяці тому

    5:35 end of DIP and start of IOC

  • @xerxesking6734
    @xerxesking6734 11 місяців тому

    Awesome 👌

  • @JackFord322
    @JackFord322 11 місяців тому

    What tool do you use to draw in your videos?

  • @djscratchnsniff
    @djscratchnsniff 11 місяців тому

    thanks for the video

  • @FarmerWidmo
    @FarmerWidmo 11 місяців тому

    Silly question, but what if GithubClient accepted some parameters as well? How would I register it in the DI container?

    • @PedroBarbosaRoman
      @PedroBarbosaRoman 11 місяців тому

      Yes, I think you will have to do it. If you don't there could be an error in runtime possibly since the DI library he is using seems to be like that. There are also build time DI frameworks I think. Android developer here so take this with a grain of salt!

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

    Awesome

  • @cyra9544
    @cyra9544 7 місяців тому

    Thanks a lot!

  • @daver94
    @daver94 11 місяців тому

    Thanks ❤

  • @devgenesis6436
    @devgenesis6436 11 місяців тому

    what is the tool fro drawing diagrams in vscode

    • @devfric3149
      @devfric3149 10 місяців тому +1

      It might be a tool on the video recording sofware but not sure what he is using.

  • @SpaceBrain-1
    @SpaceBrain-1 3 місяці тому

    My brain thanks you

  • @danielrobinson8629
    @danielrobinson8629 10 місяців тому

    סרטון מעולה אחי, מאיפה האנגלית?

  • @cuongday9005
    @cuongday9005 8 місяців тому

    skills of 9.0-IELTS Listener

  • @andrijs1521
    @andrijs1521 3 місяці тому

    your missing timestamps for each one :/

  • @g3ff01
    @g3ff01 6 місяців тому

    Go ahead and tell us: did you lose some bet so you had to go ahead and tell "go ahead and..." every time you go ahead and say a verb?