Introduction
If you happen to be working in a statically typed language, there's a pretty good chance you'll have brushed up against Dependency Injection or the Dependency Inversion Principle. The former has led to many frameworks that have sprouted up making this easier to achieve in a static language, whereas dynamic languages like Ruby don't really need the frameworks. The Principle, however, still applies in order to achieve good software.
You just have to do a basic search to come up with a plethora of links to information on the topic, and yet many developers are still no closer to grokking it. So we've scoured a few places and tried to make the filter slightly more geared towards understanding what it means, and when to use it.
So without further ado, let's see what the experts have to say when we take a good hard look at Dependency Injection and Inversion:
Injection is not the same as Inversion

The basic premise boils down to this:
- Dependency Inversion Principle is a pattern which seeks to decouple a module that defines and uses a specific Policy, from a module that defines the Details of implementation, and making the Details depend on the Policy. Having it the other way around is all too common, and creates many of our problems in every day software development.
- Dependency Injection is also a pattern, a complimentary one if you like, describing means by which a module obtains an instance of a dependency it needs in order to perform its function. While that is demonstration of loose coupling to a certain extent, it is entirely possible for your code to use Dependency Injection to push a Policy module into the constructor of a Details module, and still violate Dependency Inversion because the dependency is pointing in the wrong direction.
While you're at it, don't forget to take a look at two more very good posts by Derick on the subject that might help pierce the fog:
- Dependency Inversion: ‘Abstraction’ Does Not Mean ‘Interface’
- DI and IoC: Creating And Working With A Cloud Of Objects
Dependency Injection For Dummies

And you know what? That's totally fine because as long as you're willing to learn, there's someone willing to teach, and Kevin does exactly that in this short and sweet post that'll get you going with the basics.
Dependency Injection 101

He covers everything from the motivations for use and how they came about through building up a simple service to show how each of the concepts has its place and gives a very well rounded account of the slightly more in-depth concepts of Inversion of Control containers.
Foundations of Programming – Dependency Injection

Karl is outlining some further concepts in his second edition of the book which is still a work in progress, but looks very interesting nonetheless. He still comes back to the same concepts as many others in this well written piece - reducing coupling between modules is key to a flexible and maintainable design.
The Dependency Inversion Principle (PDF)

This article is not for the faint of heart, to be sure, but if you're looking for something to file alongside the technical documentation for your architecture, you'd do well to include this one. It covers everything from the initial premise, through to example and possible expansions on the idea.
IoC Containers and the Dependency Injection pattern

On the down side, it is very long and more akin to reading a chapter of a book rather than a post on the subject. The other problematic part is that certain pieces of the work have started to show some cracks over time and use, for example, the Service Locator pattern described in the text is now widely accepted by many as an anti-pattern and that developers should steer clear of using it. That doesn't mean that Dependency Injection becomes a bad idea, just as with all things, there are good ways and bad ways of doing it.
Dependency Injection is Loose Coupling

Mark is passionate about the topic, and his teaching style is straight forward and to the point. It's exactly what you need when dealing with something like this. There are too many fluffy opinions out there to muddy the waters, but if you're looking to get a good understanding of the good and the bad, then this is where you want to start looking.
Oh - and I would highly recommend buying his book should you be delving in deep. It is a quality read.
Conclusion
When it comes to statically typed languages, after the hard and often painful lessons we've learned over the last few years, there can be no doubt that making use of this technique will make for more robust and maintainable code. In addition, we also know that using a container is pretty much a given if at all possible in order to remove as much boiler plate code as possible.
I hope this has provided an insight for you to take this idea further and please do let me know if you've stumbled across an excellent resource yourself that you'd like me to include and I'll gladly do so with credit to you for the find!
Until next time,
RobertTheGrey