dependency-injection - 为什么用这么多术语来表达同样的事情? IoC 和 DI

IoC = 控制反转

DIP = 依赖倒置原则(S.O.L.I.D. 中的 D)

IoC == DIP?我认为是的,是真的。

构建软件的世界已经这么乱了,为什么要说同样的话那么多话?

(我知道DI(依赖注入(inject)),它不同于DIPIoC)

更新:

根据答案,那么我们可以说:(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/

相关文章:

c# - 有没有办法在没有 return 语句的情况下在函数中返回默认值?

macos - sudo 命令后出现段错误

r - 分成3个字符长度

mobile - 移动客户端的 websockets

objective-c - 在 UIImageView 之上覆盖 UIImage,可能吗?示例代码?

ruby-on-rails-3 - 从 Rails 中的模型获取图像路径

groovy - 在 Groovy 中使用 When and Then?

php - 在 PHP 中使用不可打印字符作为分隔符?

php - Wordpress - 按日期范围获取帖子

r - 在 R 中缩放数据忽略特定列