是的IDependencyResolver一个反模式? [英] Is IDependencyResolver an anti-pattern?

查看:106
本文介绍了是的IDependencyResolver一个反模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一些建筑变成一个传统的ASP.NET应用程序。我有些原型类依赖分辨率模仿ASP.NET MVC的的IDependencyResolver。我不会发布,因为它是pretty很多相同的接口,但在其他的自然语言。

I am designing some architectural changes into a legacy ASP.NET application. I prototyped some classes for dependency resolution that mimic the ASP.NET MVC's IDependencyResolver. I won't post because it is pretty much the same interface, but in other natural language.

我想通了,它可能会被认为是服务定位,这又是通常谴责(不完全在某些情况下)有利于依赖注入。不过,我找不到反对使用ASP.NET MVC的依赖解析执行任何建议。

I figured out it might be considered Service Location, which in turn is usually (not fully in some cases) condemned in favor of Dependency Injection. Nevertheless, I couldn't find any recommendation against the use of the ASP.NET MVC's dependency resolution implementation.

时的ASP.NET MVC的考虑的IDependencyResolver反模式?它是一件坏事?

Is the ASP.NET MVC's IDependencyResolver considered an anti-pattern? Is it a bad thing?

推荐答案

如果你在看<一个href=\"http://blog.ploeh.dk/2010/11/01/PatternRecognitionAbstractFactoryOrServiceLocator.aspx\">signature你会看到,它只是一个服务定位器使用其他名称。 服务定位器是一个反模式,我认为关系传递的,所以我认为的IDependencyResolver反模式

If you look at the signature you will see that it's just a Service Locator with another name. Service Locator is an anti-pattern and I consider the relationship transitive, so I consider IDependencyResolver an anti-pattern.

除此之外,该接口也破碎,因为它没有推出方法

这篇关于是的IDependencyResolver一个反模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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