问题
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