IoC = 控制反转
DIP = 依赖倒置原则(S.O.L.I.D. 中的 D)
IoC == DIP?我认为是的,是真的。
构建软件的世界已经这么乱了,为什么要说同样的话那么多话?
(我知道DI(依赖注入(inject)),它不同于DIP和IoC)
更新:
根据答案,那么我们可以说:(DI) + (IoC) = (依赖倒置原则) ?
最佳答案
控制反转是通用术语。依赖注入(inject)是一种特定类型的 IoC。
参见 Inversion of Control Containers and the Dependency Injection pattern .
Dependency Inversion Principle是指南,而其他术语是对技术的描述。 (IoC 也可以用来描述一个原则,所以这很容易混淆。)
用在一句话中:
Sue followed the Dependency Inversion Principle by using Dependency Injection in the constructor of her class and creating instances with an Inversion of Control container.
更新:
我不认为 (DI) + (IoC) = (Dependency Inversion Principle) 是准确的。这就像说(Apple) + (Food) = (Good Nutrition)。每个术语都有特定的含义。
关于dependency-injection - 为什么用这么多术语来表达同样的事情? IoC 和 DIP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7327822/