Тёмный

Dependency Injection in C# ❘ A Hands-On Guide to Boosting Code Flexibility and Testability 

Skill Foundry
Подписаться 4,3 тыс.
Просмотров 17 тыс.
50% 1

Welcome back to Skill Foundry! Today, our expert Eric Wise will demystify Dependency Injection, a must-know for any coder aiming for better code flexibility and testability. We'll kick off with an overview before diving into hands-on coding, using C# to transform a basic Rock-Paper-Scissors game through Dependency Injection. This tutorial is useful for developers at all skill levels and will also cover common pitfalls and their solutions. After setting the stage with a theoretical framework, we'll transition into a hands-on coding session. Eric takes a straightforward but tightly coupled Rock-Paper-Scissors game coded in C# and demonstrates the transformative process of refactoring it into dependency-injected components using interfaces. This practical example will not only demystify the concept but also show you how to put it into practice in your own coding endeavors.
➡️ Whether you're just starting out or are an experienced developer in need of a refresher, this tutorial is crafted to be valuable for all skill levels. We'll also shed light on the common pitfalls developers encounter when neglecting to use Dependency Injection and provide actionable solutions for overcoming these challenges.
By the end of this video, you'll have a solid grasp of how designing classes for Dependency Injection allows for the swapping of behaviors and facilitates easier unit testing. These benefits, in turn, prepare you for more complex and advanced development projects, making this skill indispensable in your coding repertoire. Don't miss this chance to elevate your development skills. Be sure to subscribe to our channel and activate notifications so you're always in the loop. Thank you for tuning in, and we look forward to assisting you in your journey to becoming a more skillful developer.
📍 Find Us Elsewhere:
linktr.ee/skillfoundry
💬 Did you like this video? Let us know in the comments below!
✅ Click here to subscribe to Skill Foundry now!
www.youtube.com/@SkillFoundry...
---------------
Welcome to the official RU-vid channel of Skill Foundry - Learn to Code! Build an Unshakeable Foundation ☑️
With years of experience in shaping talent across corporate offices, universities, and innovative coding boot camps, we've mastered the art of guiding you from scratch to an employable level of coding expertise. Our ability to deeply understand the challenges you face as an aspiring coder sets us apart. Each video we create is crafted to specifically address these pain points, enabling you to overcome common hurdles. At Skill Foundry, we strongly believe in the transformative power of education. Our mission goes beyond just teaching code; we aim to empower you with the skills and knowledge you'll need to excel in the ever-changing landscape of technology. Whether you're contemplating a career change, fresh out of school, or an enthusiastic self-learner, we're committed to providing you with all the tools necessary for a successful technical education journey.
➡️ Our learning approach is distinctive. We're not just about lectures and theory. Our videos blend theoretical concepts with hands-on exercises and real-world projects. This holistic method ensures that you're not just memorizing information but also applying what you've learned in practical, job-relevant scenarios. This means you gain both the confidence and the competence to tackle complex coding challenges, setting you up for long-term success in the industry.
Expect weekly coding tutorials that range from the simplest 'Hello, World!' to complex algorithms, interactive Q&A sessions with industry professionals, career-building strategies, project walkthroughs, and much more. Our aim is to serve as your all-inclusive resource for coding education.
Join us in our exciting educational adventure as we equip you with the key skills to excel in tech. Together, let's code your future! So, hit the subscribe button and turn on the notification bell so you won't miss any new videos! 🔔
---------------
💥 Learn to Code! Build an Unshakeable Foundation.
www.skillfoundry.io/
📬 Contact us anytime!
www.skillfoundry.io/contact-us
---------------
#SkillFoundry

Опубликовано:

 

23 авг 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 86   
@SkillFoundryIO
@SkillFoundryIO 13 дней назад
If you like this video and want to learn C# in depth from me, visit www.skillfoundry.io! The learning pathway takes you from zero to professional-level coding skills, but be prepared for rigor and depth. It takes over 700 hours to complete, with 80+ exercises and 12+ substantial capstone projects.
@guavavodka
@guavavodka 9 месяцев назад
If anyone is curious why it's called dependency inversion, it is because instead of the class depending on lower level details (where the choices come from), it now depends on a HIGHER level abstraction (the interface), thus the dependencies were inverted
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Absolutely! I left that term off the video because most novices only hear about the injection part. 😇 Thanks for adding more information!
@RogerDunder
@RogerDunder 2 месяца назад
That was the easiest most clear explanation i found so far, thank you so much!
@SkillFoundryIO
@SkillFoundryIO 2 месяца назад
You are very welcome!
@julieyeaeun
@julieyeaeun 5 месяцев назад
Eric you are an AMAZING teacher! Sincerely, a former teacher turned programmer :)
@SkillFoundryIO
@SkillFoundryIO 5 месяцев назад
Thank you!
@christianfredrickgerman9170
@christianfredrickgerman9170 2 месяца назад
Thanks. You explain DI so clear and simple that even non programmer can understand.
@gracicot42
@gracicot42 6 месяцев назад
Hi! I'm the creator of the kangaru dependency injection library for C++. What I love about that tutorial is that you teach beginners to do it without a framework. A dependency injection library is only there to automate boilerplate that happens in the wiring code, and not essential for dependency injection. Another point (for more advanced programmers) is that technically, dependency injection don't require interfaces to work. union (sum types) or enums can also do the trick when you want your component to let users choose its behaviour, but have a closed set of possible behaviour. This still enable testing without introducing virtual function calls when unneeded. In my case, which might be a C++ only thing, adding virtual functions (any overridable function) strictly only for the purpose of testing is smelly code. I try to keep behaviour choices as closed as possible and thus do my DI with concrete types when possible with the choice of behaviour being values inside those concrete types.
@SkillFoundryIO
@SkillFoundryIO 6 месяцев назад
Thank you for your kind words! I agree on the virtual methods as well, it’s a smelly pattern.
@gracicot42
@gracicot42 6 месяцев назад
@@SkillFoundryIO Yeah, but definitely something that will only appear with larger projects, or projects with tight performance requirements. Out of the scope of the video, but still worth mentioning here in the comments :)
@michi1106
@michi1106 10 дней назад
Love the short but rly clearly overview and example, of what dependency injection is. At the begin i thought it was some evil stuff, but learned fast, its simple and rly helpful.
@KnightMirkoYo
@KnightMirkoYo 9 месяцев назад
Wow, really cool. I've been doing it a lot in my code, but didn't have a complete understanding of how powerful it is
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
I’ve noticed a lot of tutorials show how but don’t spend much if any time on the why. It’s one of the reasons in our courses we refactor projects as we learn new techniques so our learners can better see the difference between novice and professional approaches!
@mitkram99
@mitkram99 9 месяцев назад
This is exactly the approach we took in our project. OOP in C# is not complete if not done with DI. Dependency Injection was intimidating at first but once you fully understood its principles, you'll get addicted to using it in your OOP implementation.
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Agreed! There is always a trade-off for complexity, so for really simple things like batch jobs I sometimes skip it, but for the most part you should be implementing it, especially between layers of your project.
@stressfreesid9498
@stressfreesid9498 21 день назад
I will say you are the great master teacher. You have extra ordinary skills and techniques for teaching lots of blessing from all who watched this videos.
@SkillFoundryIO
@SkillFoundryIO 21 день назад
Thank you!
@panic_seller
@panic_seller 9 месяцев назад
saw this in a Job Description and Now seeing it on RU-vid all in less than 2 hours, The gods wanted me to learn this
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Hope it helped! If you want to go deeper into it in C#, check out our main site.
@PrettyBlueThings
@PrettyBlueThings 2 месяца назад
Excellent explanation!
@alfonzo6320
@alfonzo6320 Месяц назад
This is an excellent video!
@aluminatsulana
@aluminatsulana 17 дней назад
This was some incredible explanation! I was realy struggleing with the concept at first but now after the video how I even struggled at the first place! Great video!
@SkillFoundryIO
@SkillFoundryIO 17 дней назад
Everyone struggles at first my friend
@marceloleoncaceres6826
@marceloleoncaceres6826 18 дней назад
GREAT example, thanks for sharing it!
@SkillFoundryIO
@SkillFoundryIO 18 дней назад
You are welcome!
@TheSopk
@TheSopk 10 дней назад
So clear, first time I understand how usefulin dependency injection.
@SkillFoundryIO
@SkillFoundryIO 10 дней назад
Thank you!
@martinroa
@martinroa 2 месяца назад
This video is gold.
@investinglearningmachine3951
@investinglearningmachine3951 3 месяца назад
Hey, this is the best explanation and examples. Thank you so much!
@SkillFoundryIO
@SkillFoundryIO 3 месяца назад
You are welcome!
@HiwashiYT
@HiwashiYT 7 месяцев назад
What an amazing explanation for a very confusing topic to beginners like myself, you even added the testing example that so many people mention but never show! Great work, will definitely follow your channel for more content.
@SkillFoundryIO
@SkillFoundryIO 7 месяцев назад
Thank you for your kind words!
@user-dy1nf2ht9x
@user-dy1nf2ht9x Месяц назад
Amazing video 👌👌
@EA33964
@EA33964 2 месяца назад
Best explanation so far. So glad I found your video. Thanks
@randallholmes4282
@randallholmes4282 6 месяцев назад
Beautiful! Thank you!
@SkillFoundryIO
@SkillFoundryIO 6 месяцев назад
You are welcome!
@joekimbler
@joekimbler 3 месяца назад
Fantastic explanation and example for DI!! You teach both the concept of DI as well as how it is implemented in c#. Simple and to the point. Great job.
@SkillFoundryIO
@SkillFoundryIO 3 месяца назад
Thank you for your kind words!
@justHeisen
@justHeisen 4 месяца назад
You have the perfect pace for teaching.
@SkillFoundryIO
@SkillFoundryIO 4 месяца назад
Thank you!
@gregschlitt3847
@gregschlitt3847 Месяц назад
Nice work, with a well chosen example
@user-dy1nf2ht9x
@user-dy1nf2ht9x Месяц назад
Great video
@Salvotation
@Salvotation 9 месяцев назад
I’m learning programming as a hobbyist and to make my work life easier. I am at the stage where I have learnt the basic C# syntax and solving individual problems. Now trying to start learning OOP, this is a really helpful approach to start understanding it’s uses!
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Stay motivated! OOP is the hardest part, once you get it the rest is not nearly as difficult to learn.
@StefanoTurcarelli
@StefanoTurcarelli 2 месяца назад
Thank you so much for this amazing example!
@SkillFoundryIO
@SkillFoundryIO 2 месяца назад
You're very welcome!
@JanKowalski-ld4ec
@JanKowalski-ld4ec 4 месяца назад
I'd been lookin for good interface explanation until I found your channel. And you did best of what you could. Explained interfaces and DI at once, on working example. Fantastic job! Great content, great teaching approach, wide perspective filled with necessary details without overhelming the learner and topic. All the best for you and your channel!
@SkillFoundryIO
@SkillFoundryIO 4 месяца назад
Thank you!
@ernestocampese
@ernestocampese 21 день назад
Very well explained. Great job, thank you 👍
@SkillFoundryIO
@SkillFoundryIO 21 день назад
Thank you for your kind words!
@Speak4Yourself2
@Speak4Yourself2 9 месяцев назад
NIce tutorial! Thanks a lot! Promising channel.
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Thank you for the kind words!
@user-li2dm5rz6l
@user-li2dm5rz6l 3 месяца назад
this was amazon explanation, I love it, thank you
@SkillFoundryIO
@SkillFoundryIO 3 месяца назад
You are welcome!
@Krissini
@Krissini 3 месяца назад
fantastic video, beautifuly explained and an easy to follow and recode example. Thank you!
@SkillFoundryIO
@SkillFoundryIO 3 месяца назад
Thank you!
@waynegreen7970
@waynegreen7970 4 месяца назад
Good content!
@Mamika_AFK
@Mamika_AFK 9 месяцев назад
Another great video! Keep it up! 😄👍
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Thanks! Will do!
@Director414
@Director414 2 месяца назад
Great video! You really good at explaining stuff, well done! Impressive. Keep up the good work!!
@SkillFoundryIO
@SkillFoundryIO 2 месяца назад
Thank you for your kind words!
@user-xp4yq2jd7s
@user-xp4yq2jd7s Месяц назад
Thank you sir you’ve saved me ❤️ you way of explaining the concept is really amazing and the example itself is simple. Please explain the dependency injection container too 🙏 thanks again
@SkillFoundryIO
@SkillFoundryIO Месяц назад
You are welcome!
@userman444
@userman444 3 месяца назад
Thank you! Found something new :)
@SkillFoundryIO
@SkillFoundryIO 3 месяца назад
You are welcome
@schmidtlach
@schmidtlach Месяц назад
I have been searching for weeks and watching tens of videos on the subject. I finally found it on your channel. Thank you for sharing 😂. It's clear to me now. I'm subscribing to your channel 😊.
@SkillFoundryIO
@SkillFoundryIO Месяц назад
Glad it was helpful!
@SeraphixD3
@SeraphixD3 9 месяцев назад
Nicely explained
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Thank you!
@mahmoudmohammed9287
@mahmoudmohammed9287 9 месяцев назад
Nice explanation keep it up❤
@SkillFoundryIO
@SkillFoundryIO 9 месяцев назад
Thanks 🙂
@bamf75
@bamf75 3 месяца назад
really nicely done...any chance you could do a DI container video?
@ninjask8ter
@ninjask8ter 8 месяцев назад
This video was a great refresher especially after being away from it for so many years! Is there any available code so I can save?
@SkillFoundryIO
@SkillFoundryIO 8 месяцев назад
Sorry, I haven't set up a GitHub repository for the RU-vid channel. Honestly didn't think about it. I'll put that on my list of things to do this month.
@ahmedh2482
@ahmedh2482 17 дней назад
you are awesome
@Decapodd
@Decapodd 13 дней назад
made me smile
@joelmatthews3255
@joelmatthews3255 23 дня назад
Great video. My only recommendation is to maybe forgo the background music. I personally found it a little distracting while trying to concentrate on your voice at times.
@SkillFoundryIO
@SkillFoundryIO 23 дня назад
Good feedback, thank you!
@CHURUTEInternational
@CHURUTEInternational 5 месяцев назад
2 questions. are you in your bath tub? and does this work the same if I want to use dependency injection in xamarin forms or MAUI?
@SkillFoundryIO
@SkillFoundryIO 5 месяцев назад
1. I’ve been upgrading my gear. Didn’t want to over invest if the channel didn’t take off. 2. Yes it works the same.
@LuisSieira
@LuisSieira 28 дней назад
Very good video. Just... I'm not fan of the Iplayer nomenclature... the client of the API you defined does not care if it is interacting with an interface or an implementation. You manager talks to a Player, not to an IPlayer. Same way you interact with a List, not an Ilist, that you can new ArrayList, but the list is not an IList, and the ArrayList is not a ListImpl (I am not fan of the PlayerImpl either). You have a public interface Player, and a public class HumanGamer implements Player, and a BipBoopRandomGambler implements Player...
@SkillFoundryIO
@SkillFoundryIO 28 дней назад
That’s mostly a c# thing. Most devs use the I prefix.
@user-vi7xn1tj9f
@user-vi7xn1tj9f 13 дней назад
lol. a switch statement anyone?
@SAAbir-si8wk
@SAAbir-si8wk 16 дней назад
I can never thank you enough! God, It's a gem! The example, the explanation, the accent, the pace.... it's perfect! damn! 🤌🤌 One other thing. The background sound-track is so soothing! What's the track name?
@SkillFoundryIO
@SkillFoundryIO 16 дней назад
Not sure on the music, my editor uses epidemic sound subscription. They have a lot of music like that.