What is dependency injection?
DI is a way to apply the IoC principle. IoC is a broader version of the dependency inversion principle (the D in SOLID). In essence, while IoC is about shifting the control of the program’s flow to a separate component or framework to increase modularity, the DIP focuses on how modules or classes are interconnected.
The idea behind DI is to move the creation of dependencies from the objects themselves to the composition root. That way, we can delegate the management of dependencies to an IoC container, which does the heavy lifting.
An IoC container and a DI container are the same thing—they’re just different words people use. I use both interchangeably in real life, but I stick to the IoC container in the book because it seems more accurate than a DI container.
IoC is the concept (the principle), while DI is a way of inverting the flow of control (applying IoC). For example, you apply the IoC principle (inverting...