Is the dependency injection a cross-cutting concern?

风流意气都作罢 提交于 2020-01-15 11:48:11

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/13382560/is-the-dependency-injection-a-cross-cutting-concern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!