控制的依赖注入和反转 - 术语 [英] Dependency Injection and Inversion of Control - terminology

查看:107
本文介绍了控制的依赖注入和反转 - 术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在函数式编程中,函数被视为实体,可以作为对象在OO上下文中传递。



在某个级别上,函数可能是'所谓的'带有一些参数。

我想知道:这也叫做依赖注入吗?



此外:DI的这种用法是否导致控制反转?

解决方案

依赖注入是一个概念。

你也许可以用功能语言实现DI(将函数作为参数传递)。
可以有很多方法来实现DI,每种语言都可能有实现DI的方式。

DI是IoC的一种特殊形式。因此,所有DI都是IoC,但不是相反。
所以你说得对DI的这种使用导致IoC是正确的。


In functional programming, functions are regarded as entities, and can be passed around as objects are in an OO context.

At some level, the function may be 'called' with some arguments.

And I was wondering: is this, too, called Dependency Injection?

And further: does this usage of DI result in Inversion of Control?

解决方案

Dependency Injection is a concept.

You could perhaps "implement" DI in functional languages using this (the ability to pass functions as parameters). There could be many ways to achieve DI and each language might have its ways of implementing DI.

DI is a specialized form of IoC. Thus all DI is IoC but not the other way round. So you are right in saying that this usage of DI results in IoC.

这篇关于控制的依赖注入和反转 - 术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆