我们是否使用依赖注入技术实现了依赖倒置原则?
我对么?
是的。依赖倒置说“不要自己寻找依赖,它们会提供给你。” 依赖注入是一种从外部向对象提供依赖的方法。
是的
两句话的依赖倒置原则:
High level modules should not depend upon low level modules. Both should depend upon abstractions.
和
Abstractions should not depend upon details. Details should depend upon abstractions.
尽管
依赖注入模式是应用程序/代码组合问题的具体解决方案之一。是的,这个解决方案是依赖倒置原则的实现。最著名的阅读地点可能是 Martin Fowler - Inversion of Control Containers and the Dependency Injection pattern。