Dependency Injection and Inversion of Control - terminology

梦想与她 提交于 2019-12-07 15:48:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/954913/dependency-injection-and-inversion-of-control-terminology

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!