Dependency Injection Pattern

In software engineering, dependency injection is a software design pattern that implements inversion of control for software libraries. Caller delegates to an external framework the control flow of discovering and importing a service or software module specified or "injected" by the caller. Dependency injection allows a program design to follow the dependency inversion principle where modules are loosely coupled. 


With dependency injection, the client which uses a module or service doesn't need to know all its details, and typically the module can be replaced by another one of similar characteristics without altering the client.



There are three common forms of dependency injection: 

setter-, interface- and constructor-based injection, where the responsibility of injecting the dependency lies upon the client, the service or the constructor method respectively.


参考文献:

[0]  Dependency injection  http://en.wikipedia.org/wiki/Dependency_injection

你可能感兴趣的:(Pattern,dependency,injection,design)