Difference between dependency injection and dependency inversion

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • iOS Cafe discord server link: / discord
    The difference between dependency injection and dependency inversion principle is a well know iOS interview question for experienced developers and since the concepts are pretty much identical it sometimes becomes confusing as to how to explain these topics to the interviewer.
    In this session, we will explore these topics and will try to understand the difference between them
    Given are the chapters for today's video
    0:00 introduction
    1:00 dependency injection
    1:10 codecat15 example
    2:10 dependency injection definition
    3:25 dependency injection demo
    5:23 issues with dependency injection
    7:59 dependency inversion
    8:34 dependency inversion demo
    9:52 summarizing
    10:47 discord server annoucement
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ✅ Subscribe to the channel and stay ahead of everyone by following the right way for writing clean code in swift. 🔥🔥🔥🔥🔥
    🔗Click on the link to subscribe: ruclips.net/user/codecat?sub...
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    -----------------------------------------------------------------------------------------------------------------------
    Given are the video links mentioned
    1. Dependency inversion video: • Dependency inversion p...
    2. Dependency injection video: • Dependency Injection I...
    3. SOLID principle playlist: • Code like a pro swift ...
    -----------------------------------------------------------------------------------------------------------------------
    ############################################
    Connect with me on social media
    📧: codecat15@gmail.com
    🐦: / codecat15
    Facebook: / code.cat.792
    Github: github.com/codecat15
    ###########################################
    #dependencyInversionSwift #dependencyInjectionSwift #cleanCodingSwift

Комментарии • 80

  • @akhilgupta6883
    @akhilgupta6883 8 месяцев назад +2

    Dependency Inversion is dependency injection using protocols -- Simple and best explanation.
    Thank you Ravi for your cleanest explanation.

  • @rajeshpothuraju5281
    @rajeshpothuraju5281 2 года назад +2

    Ravi, Your explanation is very clean and easy to understand. Anyone can understand the concept from beginners to pro level. Thank you so much.

    • @CodeCat15
      @CodeCat15  2 года назад

      Thank you for your kind words

  • @hemantvitthal3732
    @hemantvitthal3732 2 года назад

    Thank you for making video in hindi language. I understand all concept. You doing great jobs.

  • @awais.fayyaz
    @awais.fayyaz 2 года назад +1

    Thank you very much for what you are doing. I very much like the Nice and clear explaination of these concepts.

    • @CodeCat15
      @CodeCat15  2 года назад

      Thank you for your kind words and I am glad the video was helpful. 👍

  • @satyamkumar-mb4sd
    @satyamkumar-mb4sd 2 года назад +1

    Thank you so much Sir, both keywords differences are now very clear.

    • @CodeCat15
      @CodeCat15  2 года назад

      Excellent, glad to know the video was helpful

  • @mafarunnisap.k5151
    @mafarunnisap.k5151 2 года назад +1

    Thanks a lot Ravi. Simple, clear and concise..

  • @AbdulRehman-mk1fz
    @AbdulRehman-mk1fz 2 года назад +1

    Awesome explanation. Much appreciated ♥

    • @CodeCat15
      @CodeCat15  2 года назад +1

      Glad this was helpful 😊

  • @amarshirke31
    @amarshirke31 2 года назад +1

    Thank you very much Sir, Finally my doubt got resolved 😊

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad it was helpful 👍

  • @nilanjanmajumder9831
    @nilanjanmajumder9831 Год назад

    explained very nicely ✌

  • @monikaraut5266
    @monikaraut5266 Год назад +1

    You cleared my doubts
    Thank you so much 👍

    • @CodeCat15
      @CodeCat15  Год назад

      Welcome to the channel Monika, and I am glad this video was helpful.

  • @umairahmad4368
    @umairahmad4368 2 года назад +1

    Thanks, Sir for describing it with an exclusive CodeCat15 example :)

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad the example was helpful 😊

  • @JunaidKhan-ny8tu
    @JunaidKhan-ny8tu 2 года назад +3

    Thank you Ravi Bhai . We mostly use dependancy Inversion principle when creating viewContoller instance . Before that I was understanding that its dependancy injection

    • @CodeCat15
      @CodeCat15  2 года назад +1

      ViewController instance using DIP that’s great do share an example on discord if possible thanks 😊

    • @JunaidKhan-ny8tu
      @JunaidKhan-ny8tu 2 года назад +1

      @@CodeCat15 thanks I will share there

  • @umairkhan4982
    @umairkhan4982 2 года назад +1

    Great Explanation, thanks

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad it was helpful 👍

  • @AnkitGupta-hv2xe
    @AnkitGupta-hv2xe 4 месяца назад +1

    I faced the same question in interview and got confused. Now I know the difference, will shoot the answer to the interviewer now🙂.
    Thanks Ravi Sir.🙌
    Your explanation is always the best among all the iOS Creators.👏

    • @CodeCat15
      @CodeCat15  Месяц назад

      Next time you’ll surely answer more confidently Ankit. All the best for your interviews and feel free to ask more questions.

  • @SurenderSingh-lk1xy
    @SurenderSingh-lk1xy 2 года назад +1

    Thanks a lot Ravi, great job 👍

    • @CodeCat15
      @CodeCat15  2 года назад +1

      Glad this was helpful, feel free to ask questions and do share the video with your iOS group

  • @abhiram5347
    @abhiram5347 Год назад +1

    Excellent session sir , very neatly explained

    • @CodeCat15
      @CodeCat15  Год назад +1

      Thank you Abhi, I am glad this was helpful, please feel free to ask more questions and do share the video with your iOS group.

  • @vinodbhaskar6927
    @vinodbhaskar6927 Год назад +2

    Great effort Ravi 🙌🏻

    • @CodeCat15
      @CodeCat15  Год назад

      Thanks Vinod, am glad this was helpful.

  • @SubhashJaiswar-mu1qj
    @SubhashJaiswar-mu1qj 17 дней назад

    best example great

  • @sanjeevreddy1756
    @sanjeevreddy1756 Год назад +1

    thanks for the greate explaination

    • @CodeCat15
      @CodeCat15  Год назад

      Am glad this was helpful Sanjeev

  • @atulkumar-bb7vi
    @atulkumar-bb7vi Год назад +2

    Very clear explanation but you missed very important fact here that why we need to use dependency injection and not to create the class objects in the class. This is because we can pass different implementations of that dependencies at the runtime. So by using dependency injection, we are binding class signature not the concrete implementation util runtime. Actual implementation can be decided runtime and can be changed with any other implementation without making any changes within all classes which are using that dependency. Thanks!

    • @CodeCat15
      @CodeCat15  Год назад +1

      That’s a good catch Atul and thank you for bringing it up. If my memory serves me right I did explain this in some other video I think it could be the protocol series but yes this is the true power of DI

  • @vishalbhai123
    @vishalbhai123 Год назад +1

    Bhaji you are the best. I learn a lot from your videos. I got lot offer letters 😊 just because of you. Thanks a ton.

    • @CodeCat15
      @CodeCat15  Год назад +1

      Kya baat hai congratulations Anirudh 🎉

    • @vishalbhai123
      @vishalbhai123 Год назад +1

      I am waiting for combine framework videos. Please create videos on some concepts of combine 😜

    • @CodeCat15
      @CodeCat15  Год назад +1

      I have a playlist on combine which should get you started and as a matter of fact today I released a video showcasing all the misleading practices that are spread on the internet for combine and I strongly recommend you to check that out and share with your iOS group so that such bad practices can be avoided in the iOS community
      Video link: ruclips.net/video/fThwWm-Tv7c/видео.html

  • @krishramakrishna9567
    @krishramakrishna9567 2 месяца назад

    Please explain what's problem ic we create a object inside another class

  • @thestreetboy03
    @thestreetboy03 2 года назад

    Ravi ,plz make a video on swinject for DI

  • @dhavalnena7386
    @dhavalnena7386 Год назад +1

    Excellent!

    • @CodeCat15
      @CodeCat15  Год назад

      Many thanks, glad this was helpful

  • @haroonurrasheed4340
    @haroonurrasheed4340 Год назад +1

    Great job keep it up.

    • @CodeCat15
      @CodeCat15  Год назад

      Thank you Haroon, am glad this was helpful

  • @buba7456
    @buba7456 2 года назад +1

    Thank you Ravi.love it.. Can you please make a video on how to integrate fastlane in our project(with Demo)

    • @CodeCat15
      @CodeCat15  2 года назад +1

      I have no experience with fastlane but maybe azure, let's see

  • @prataprana2963
    @prataprana2963 2 года назад +1

    Great video❤️❤️👏🏻

    • @CodeCat15
      @CodeCat15  2 года назад

      Glad this was helpful bro 😎

  • @shaikhrakib3247
    @shaikhrakib3247 2 года назад +3

    Great video

  • @jaspreetsingh-nh7kn
    @jaspreetsingh-nh7kn Год назад +1

    Awesome👌👌

    • @CodeCat15
      @CodeCat15  Год назад

      Thanks, glad it was helpful

  • @ranjanmondal1340
    @ranjanmondal1340 2 года назад +1

    Nice video ❤️ But after watching this video I have a small doubt about what is encapsulation and abstraction ? Now I am getting confuse with this two.

    • @CodeCat15
      @CodeCat15  2 года назад

      Abstraction is giving relevant information when asked and encapsulation is hiding all the details, I wrote an article on this on medium do check it out and ask questions if you still have them
      medium.com/@codecat15/object-oriented-programming-principles-simplified-22484edf42d7

  • @vaibhavr43
    @vaibhavr43 2 года назад

    Crystal clear

  • @harshilparmar9076
    @harshilparmar9076 2 года назад +1

    That first line bro 🎯

  • @Shade_with_me_7
    @Shade_with_me_7 2 года назад +1

    Hi Ravi
    Thanks for the making amazing videos to clear out our doubts/concepts
    As given link in description for the invitation of the Discord, I am unable to enter Captcha in input field because in my case it says it is only read only channel
    You can please help me in this case.
    I will be thankful.

    • @CodeCat15
      @CodeCat15  2 года назад

      Okay I'll check it out, you may want to confirm your phone number with discord before it allows you to enter the details that's a validation I added to avoid bot spamming, if you have already done that then please ping me on discord I'll help you out

  • @TJ-16
    @TJ-16 2 года назад +1

    Nice video, can we use dependency injection in unit test case while writing api calling test cases?

    • @CodeCat15
      @CodeCat15  2 года назад +1

      Sure we can, when you create the object of the class then you would have to pass the dependency for the functionality to make it work OR you can also use mocks but I don’t recommend mocks if you can hit a API in sandbox environment of yours or maybe dev too

    • @TJ-16
      @TJ-16 2 года назад

      @@CodeCat15 Ok we have to used actual data instead of mock data for test cases, right ?

  • @abhinavmandloi
    @abhinavmandloi 2 года назад +1

    Hi,
    Your explanation is very clean :) Can you please make a series of videos on Unit test cases??

    • @CodeCat15
      @CodeCat15  2 года назад +1

      There’s a playlist on test cases do check it out, let me know if that helps
      ruclips.net/p/PLb5R4QC2DtFtDhqnkOsjHElzg_GzJiPTa

  • @waheedafolabi6929
    @waheedafolabi6929 2 года назад +1

    Thanks 🙏 Ravi

  • @deepakkuar1407
    @deepakkuar1407 2 года назад +1

    nice video bro.

    • @CodeCat15
      @CodeCat15  2 года назад

      Thanks, I am glad this was helpful

  • @Ankit-ug7ep
    @Ankit-ug7ep 2 года назад +1

    What is the issue if we make instance of LoginAPI inside LoginViewModel with private keyword?

    • @CodeCat15
      @CodeCat15  2 года назад +1

      From a clean code perspective you break single responsibility principle,
      the job of a view model is to orchestrate the calls and not have the logic to make those calls
      you may have the code inside the viewModel of URLSession or core data etc but then this gives rise to massive viewModels just like massive view controllers

    • @Ankit-ug7ep
      @Ankit-ug7ep 2 года назад

      @@CodeCat15 Thanks for quick response...I got the idea...

  • @subinsuresh3234
    @subinsuresh3234 Год назад +1

    Is it breaking Encapsulation?

    • @CodeCat15
      @CodeCat15  Год назад

      encapsulation is hiding the implementation details abstraction is providing relevant information to the client to get the job done, but sometimes when you provide something that's not required by the client we break abstraction and not encapsulation, the implementation details are always hidden from the caller of the method the caller just knows that on the tap of the button something happens and I get my data or the required function is executed
      Example: On press of the remote control button the channel is changed, you just know that on the tap of the button the channel is changed, what really happens when the button is pressed those semantics are hidden from you or should i say the implementation details are encapsulated from you and you are given an abstracted layer to interact with.
      Does that answer your question? If not please ask more

  • @z_shawgaming7134
    @z_shawgaming7134 2 года назад +1

    Creative developer's opinion 😂😂😂

    • @CodeCat15
      @CodeCat15  2 года назад +1

      hahahah that is true, but the private keyword one is a little tricky and it will work if you plan it out but then that's too much effort to maintain so not a robust solution as it has openings for errors