Dependency injection is a design principle that follows the inversion of control concept. A class should not instantiate it’s own dependencies, but rather have them configured from outside. Dependency injection wires objects in a flexible way, we can change the wiring without changing the code, and replaces the factory objects in a framework. As inversion of control is the concept behind it, dependency injection is preferred in frameworks.
READ MORE >