Inversion of Control vs Dependency Injection vs Strategy Pattern


Warning this my understanding as of today, who knows what tomorrow will bring.

I often hear the terms Inversion of Control(IOC), Dependency Injection(DI) and the Strategy Pattern thrown around in the same context, this was getting really confusing for me. So, I spent a couple of hours trying to clarify the differences.

IOC vs DI: Basically DI is a type of IOC. IOC is a broad abstract principle that covers not only DI but Event-Driven programming and numerous others.

So What is DI? DI is the way you provide the implementation for a dependent service. There are a number of DI frameworks out there I have recently been playing with Ninject mostly because I like ninjas... and the flow syntax for wiring up the dependencies looks nice.

DI vs Strategy Pattern: For a while now I have been using the Strategy pattern thinking it was the same as DI. I know, "Gosh such an idiot :p", but DI assembles the appropriate algorithms for the calling class. Strategy is just one of the patterns that lends itself well to DI.

More Info:

Dependency injection

Inversion of control

Inversion of Control Containers and the Dependency Injection pattern by Martin Fowler

Inversion of Control vs Strategy Pattern

IoC containers are not about a design pattern

Thank you, Eric Ridgeway for answering my 200 questions.