Dependency injection explained
Martin Fowler’s original article on inversion of control - now better referred to as dependency injection - is definitive but lengthy. And in all the verbiage the central message gets lost. Instead, here’s a snappy explanation of dependency injection in bullet points (i.e. less brainwork required). It’s all the better for the hand-drawn diagrams.
Here’s my explanation in even fewer words: You don’t want to hard code dependencies into your classes, because then you can’t test them without relying on the dependent classes. So you “inject” those dependencies simply by setting them as properties - possibly in the constructor, possibly with setter methods. And it becomes all the easier if you have a little container which manages how to configure those dependencies (properties) before they’re injected (set).