VST16 Understanding Dependency Injection & Writing Testable Software

11/18/2014

4:15pm - 5:30pm

Level: Introductory to Intermediate

Miguel Castro

Miguel Castro

MRD

President

Melvicorp LLC

I'll explain dependency injection from concept to implementation, and use raw code samples to show you how it works and what problems it solves.

Dependency Injection is one of those terms that advanced programmers throw out with an expectation and assumption of full understanding on the part of the receiver. However, I constantly get asked by attendees, students, and clients to please recommend a good DI product and show them how to use it; and when I proceed to start talking about the subject, it becomes immediately apparent that many don't even know what they're asking about. It's easy to get infatuated by a cool buzz phrase, especially when you hear so many others using it. But to truly understand something you need to start by understanding the problem spaces that it is trying to solve. It's important to learn the concepts behind DI so you can write software that can be properly tested. So let's bring you totally up to speed then.

In this session, I'll explain dependency injection from concept to implementation, and use raw code samples to show you how it works and what problems it solves. I'll demonstrate how writing abstracted code can help you test your applications much better, whether or not use a DI container. Then I'll get into what a DI container is and some of the characteristics of the ones that are out there, including MEF. I'll finish by showing you implementation examples in three different platforms.

You will learn:

  • Abstraction and why it's important to testing
  • Complete explanation of DI concepts
  • What problems DI solves
  • Coverage of various DI containers
  • Writing unit tests with mocking