对照反转<依赖注入 [英] Inversion of Control &lt; Dependency Injection

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

问题描述

我感觉到有没有这样的事情是反转控制,而是正确的术语是依赖注入。我错了吗?



我一直在为自己定义IoC。在这样做的时候,我学到了很多关于IoC容器和依赖注入的信息。



刚刚,我从 Martin Fowler的网站


结果我认为我们需要一个更多
这个模式的具体名称。
控制的反转是太通用的
项,因此人们发现
令人困惑。因此,与各种IoC倡导者
进行了很多
的讨论,我们以Dependency
注入的名义结算。


在现代IoC的世界中,不是依赖注入只是实现IoC的一种方式。

解决方案

如果你接受福勒的定义,反转控制是一个比DI更广泛的术语这涵盖了您插入框架的所有框架用法,但框架仍然可以控制。



例如,在.NET中,框架例如ASP.NET或Windows Presentation Foundation最终都可以控制,但提供了可用于构建应用程序的各种事件接口。在其他平台上也是如此。



依赖注入是IoC的专业化,适用于IoC专用于管理依赖关系。


I'm getting the feeling that there's is not such thing as inversion of control or rather the correct term is dependency injection. Am I wrong to assume this?

I've been trying to define IoC for my own sake. In doing so I've learned a great deal about IoC containers and dependency injection.

Just now, I read this from Martin Fowler's website:

As a result I think we need a more specific name for this pattern. Inversion of Control is too generic a term, and thus people find it confusing. As a result with a lot of discussion with various IoC advocates we settled on the name Dependency Injection.

In the world of modern IoC isn't dependency injection just one way to achieve IoC?

解决方案

If you accept Fowler's definition, Inversion of Control is a much broader term than DI that covers all framework usage where you plug into a framework, but the framework is still in control.

For example, in .NET, frameworks such as ASP.NET or Windows Presentation Foundation are ultimately in control, but provide various events and Seams you can use to build an application. The same is true on other platforms.

Dependency Injection is a specialization of IoC that applies IoC specifically to manage dependencies.

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

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