依赖项注入是否是跨领域的关注点? [英] Is the dependency injection a cross-cutting concern?
问题描述
我正在设计一个应用程序,并且正在使用n层体系结构,我有:
- a presentation layer
- a domain bussines layer
- a data acccess layer
- a cross-cutting layer
然后,我尝试将我的项目与特定的DI框架隔离,即创建我自己的IContainer接口并确保我的组件 仅取决于此接口.
那我有两个问题.
1-这是最后的好习惯吗?
2-(更重要的是)依赖项注入是否是贯穿各领域的关注点?那可以将DI相关组件放置在横切层中吗? 如果答案不正确,那么哪里适合这些组件.
之所以这样问,是因为当我深入了解有关交叉关注点的建筑设计指南时,他们通常会提到:
- Security
- Validation
- Configuration handling
- Exception handling
- Loggings
- Caching
您是否打算更改DI框架?如果没有,则将它们抽象化是没有意义的.
DI不是一个跨领域的问题.这是一种构造对象及其之间的依赖关系的技术.I am designing an app and I am using a n-layer architecture, I have:
- a presentation layer
- a domain bussines layer
- a data acccess layer
- a cross-cutting layer
Then I am trying to isolate my project from an specific DI framework, that is create my own IContainer interface and ensure that my components depends only to this interface.
Then I have 2 questions.
1 - Is this last a good practice ?
2 - (And the more important) Is dependency injection a cross-cutting concern ? That is can I place the DI related components in the cross-cutting layer ? If the answer is not where can fits those components.
I ask this because when I dive in the architecture design guides about cross-cutting concerns they usually mention:
- Security
- Validation
- Configuration handling
- Exception handling
- Loggings
- Caching
Are you planning on changing DI frameworks? If not, there is no point in abstracting them.
DI is not a cross cutting concern. It is a technique to structure objects and dependencies between them.
这篇关于依赖项注入是否是跨领域的关注点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!