Dependency Injection and Inversion of Control - te

2019-05-12 17:06发布

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条回答
乱世女痞
2楼-- · 2019-05-12 17:31

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.

查看更多
登录 后发表回答