Advantages of dependency injection

What is dependency injection?
Put the classes with dependencies in the container, and resolve the instances of these classes, which is dependency injection. The purpose is to achieve decoupling of classes.
Advantages
1. Dependency injection reduces the coupling between a class and other classes and reduces dependencies.
2. By constructing some fake dependencies, it is convenient to perform independent tests on the Client.
3. It is convenient to separate the configuration files.
4. Reduce the construction code in the application.
5. Client is not sensitive to changes in dependencies

Guess you like

Origin blog.csdn.net/sunzheng176/article/details/114001385