问题描述
我正在将一些架构更改设计为旧版ASP.NET应用程序。我原型化了一些模仿ASP.NET MVC的IDependencyResolver的依赖解析类。我不会发布,因为它是几乎相同的界面,但在其他自然语言。
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?
推荐答案
如果你看看和另一个名字。 ,我认为关系是可转移的,所以我认为 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是否反模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!