The only thing I feel like this explanation needs is, what if I want to have both an Orc and a Goblin enemy at the same time? Besides that it is a great intro to Dependency Injection. But I feel like this is what most dependency injection intro's forget about. It is nice to be able to swap out which service is used in compile time. But with interfaces often you want to decide this during runtime no?
Thanks so much for the feedback! You’re totally right. It’s not just about swapping services at compile time. If you want both an Orc and a Goblin at the same time, you'd need a way to handle that at runtime, like using a factory. I might dive deeper into this in a follow-up video. Appreciate you pointing it out!
So this serves as a simple explanation of DI including a basic demonstration, but i'm not sure it actually explains why you would want to. Use of a REST API in the demonstration confuses things somewhat as you would expect methods on an EnemyController to receive an IEnemy on which to act rather than having one injected on controller construction. I know it was only used as an easy way to demonstrate the concept but I feel like is raises more questions than it answers.
Usaully love Patrick's videos but I agree with you on this one. The example needs to be a deeper and I think cover an actual requirement vs. some made up RPG cruft.
Pretty much. Makes the whole thing clear as mud because it got lost in the sauce. As a DI example, this would have gone into a Factory pattern that would then be used by "whatever you're doing", but instead it got thrown into the .Net API internals and it becomes "what are we talking about"? A better example would be a controller that got a "creature type", goes into a factory and gets an IEnemy for that type. And then have something like "Difficulty [Easy|Normal|Hard]" as a service injection. Now the controller can return enemy.Attack()*Difficulty(). Voila, everything is injected and the example makes sense...
Idk. Maybe to switch datasources or different logic to calculate something for different countries because of different rules and laws. But yes, I do not got the point either.
I feel the explanation is great but the payoff at the end falls flat, I've seen this with a lot of tutorials, at the end it's not clear how this will be used.
The only thing I feel like this explanation needs is, what if I want to have both an Orc and a Goblin enemy at the same time?
Besides that it is a great intro to Dependency Injection. But I feel like this is what most dependency injection intro's forget about. It is nice to be able to swap out which service is used in compile time.
But with interfaces often you want to decide this during runtime no?
Thanks so much for the feedback! You’re totally right. It’s not just about swapping services at compile time. If you want both an Orc and a Goblin at the same time, you'd need a way to handle that at runtime, like using a factory. I might dive deeper into this in a follow-up video. Appreciate you pointing it out!
I think that’s where the new Keyed services comes in. You can register both with a different key and then select at runtime by key.
So this serves as a simple explanation of DI including a basic demonstration, but i'm not sure it actually explains why you would want to. Use of a REST API in the demonstration confuses things somewhat as you would expect methods on an EnemyController to receive an IEnemy on which to act rather than having one injected on controller construction. I know it was only used as an easy way to demonstrate the concept but I feel like is raises more questions than it answers.
Usaully love Patrick's videos but I agree with you on this one. The example needs to be a deeper and I think cover an actual requirement vs. some made up RPG cruft.
Pretty much. Makes the whole thing clear as mud because it got lost in the sauce. As a DI example, this would have gone into a Factory pattern that would then be used by "whatever you're doing", but instead it got thrown into the .Net API internals and it becomes "what are we talking about"? A better example would be a controller that got a "creature type", goes into a factory and gets an IEnemy for that type. And then have something like "Difficulty [Easy|Normal|Hard]" as a service injection. Now the controller can return enemy.Attack()*Difficulty(). Voila, everything is injected and the example makes sense...
But in this case why would i want have goblin and orc at the same scope of project? because to use one i need to register and unregister the other
Idk. Maybe to switch datasources or different logic to calculate something for different countries because of different rules and laws. But yes, I do not got the point either.
Hi patrick,
Can you make one video on Iqueryable and Ienumarable.?
Hey Patrick, i applied for your job. Your description says I should contact you here.
thank you so much
Hey are you looking for a Video Editor?
I feel the explanation is great but the payoff at the end falls flat, I've seen this with a lot of tutorials, at the end it's not clear how this will be used.
Great explanation
Glad you think so! Thanks a lot for your feedback!