the conception of Dependency Injection(DI) 依赖注入的概念

dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object.

from Dependency injection from WIKI

这段话解释了为什么需要依赖注入:

The UserRepository class above needs an instance of the Webservice to do its work. It could simply create it but to do that, It would also need to know the dependencies of the Webservice class to construct it. This would significantly complicate and duplicate the code (e.g. each class that needs a Webservice instance would need to know how to construct it with its dependencies). Additionally, UserRepository is probably not the only class that needs a Webservice. If each class creates a new WebService, it would be very resource heavy.

from Managing dependencies between components