Dependency Injection di is a programming pattern and architecture model, sometimes referred to as inversion of control, although, technically, dependency injection is a special implementation of IOC, dependency injection refers to an object applying another object to provide a special ability, For example, a database connection is passed to an object's structure method instead of creating a connection within that object itself. The basic idea of control inversion and dependency injection is to transform the dependency of a class from inside the class to the outside to reduce the dependency application control inversion, when the object is created, by an external entity that regulates all objects within the system, and passes the reference of the object it relies on to it. It can also be said that the dependency is injected into the object. So, control reversal is a reversal of this responsibility about how an object obtains a reference to the object he relies on.
Dependency injection via inversion of control