(1) Why use control inversion and dependency injection
The caller does not have to care about the callee's implementation, and it does not require the caller to create the callee's instance personally, which is given to the framework to complete.
This design idea is control inversion (inversion of control, IoC), and it has another name that is dependency injection (Dependency injection, DI).
(2) What is control inversion and dependency injection
The control reversal (IOC) is controlled by the "dependencies between objects" that are programmed by the program, and the caller's instance creation work is no longer done by the caller.
Yes. Control inversion enables you to control the relationships between classes in an application by an external container. With control inversion, the callee is "injected" rather than hard-coded into
In the caller's code, this can greatly reduce the dependency between the caller and the callee.
Dependency Injection is another name for control inversion, which has the same meaning. Their essence is to change the "dependencies between objects" to rely on the IOC container.