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.👏
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!
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
Thank you Ravi Bhai . We mostly use dependancy Inversion principle when creating viewContoller instance . Before that I was understanding that its dependancy injection
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: th-cam.com/video/fThwWm-Tv7c/w-d-xo.html
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
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
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
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
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.
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
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
watched numerous videos time to time about this, this is the best explanation so far. thanks!
Glad it was helpful 😊
Dependency Inversion is dependency injection using protocols -- Simple and best explanation.
Thank you Ravi for your cleanest explanation.
Glad it was helpful
Thank you for making video in hindi language. I understand all concept. You doing great jobs.
Ravi, Your explanation is very clean and easy to understand. Anyone can understand the concept from beginners to pro level. Thank you so much.
Thank you for your kind words
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.👏
Next time you’ll surely answer more confidently Ankit. All the best for your interviews and feel free to ask more questions.
Thanks a lot Ravi. Simple, clear and concise..
You're most welcome
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!
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
Thank you so much Sir, both keywords differences are now very clear.
Excellent, glad to know the video was helpful
Thank you Ravi Bhai . We mostly use dependancy Inversion principle when creating viewContoller instance . Before that I was understanding that its dependancy injection
ViewController instance using DIP that’s great do share an example on discord if possible thanks 😊
@@CodeCat15 thanks I will share there
Thank you very much for what you are doing. I very much like the Nice and clear explaination of these concepts.
Thank you for your kind words and I am glad the video was helpful. 👍
Bhaji you are the best. I learn a lot from your videos. I got lot offer letters 😊 just because of you. Thanks a ton.
Kya baat hai congratulations Anirudh 🎉
I am waiting for combine framework videos. Please create videos on some concepts of combine 😜
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: th-cam.com/video/fThwWm-Tv7c/w-d-xo.html
Excellent session sir , very neatly explained
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.
Awesome explanation. Much appreciated ♥
Glad this was helpful 😊
You cleared my doubts
Thank you so much 👍
Welcome to the channel Monika, and I am glad this video was helpful.
Thank you very much Sir, Finally my doubt got resolved 😊
Glad it was helpful 👍
Thanks, Sir for describing it with an exclusive CodeCat15 example :)
Glad the example was helpful 😊
Great effort Ravi 🙌🏻
Thanks Vinod, am glad this was helpful.
Nice video, can we use dependency injection in unit test case while writing api calling test cases?
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
@@CodeCat15 Ok we have to used actual data instead of mock data for test cases, right ?
Great Explanation, thanks
Glad it was helpful 👍
That first line bro 🎯
🙏
Please explain what's problem ic we create a object inside another class
explained very nicely ✌
What is the issue if we make instance of LoginAPI inside LoginViewModel with private keyword?
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
@@CodeCat15 Thanks for quick response...I got the idea...
Great job keep it up.
Thank you Haroon, am glad this was helpful
Thanks a lot Ravi, great job 👍
Glad this was helpful, feel free to ask questions and do share the video with your iOS group
best example great
Is it breaking Encapsulation?
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
thanks for the greate explaination
Am glad this was helpful Sanjeev
Ravi ,plz make a video on swinject for DI
Thank you Ravi.love it.. Can you please make a video on how to integrate fastlane in our project(with Demo)
I have no experience with fastlane but maybe azure, let's see
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.
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
Great video
Glad you enjoyed it
Great video❤️❤️👏🏻
Glad this was helpful bro 😎
Excellent!
Many thanks, glad this was helpful
Awesome👌👌
Thanks, glad it was helpful
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.
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
Thanks 🙏 Ravi
Always welcome
Crystal clear
Glad it was helpful
nice video bro.
Thanks, I am glad this was helpful
Hi,
Your explanation is very clean :) Can you please make a series of videos on Unit test cases??
There’s a playlist on test cases do check it out, let me know if that helps
th-cam.com/play/PLb5R4QC2DtFtDhqnkOsjHElzg_GzJiPTa.html
Creative developer's opinion 😂😂😂
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