Where to define the interfaces for a repository in an layered architecture?

后端 未结 2 1178
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 16:56

Background

I\'m trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repo

2条回答
  •  清酒与你
    2021-02-12 17:13

    I agree with eulerfx. The only thing I would add to it is that it doesn't feel right because traditional N-tier architecture would have you make everything depend upon the database and use abstractions to break those dependencies.

    You should look at Onion Architecture which is an example of the way you are organizing your dependencies in option 4. I, personally, believe this is the most scalable architecture model available. If you couple this architecture with DDD practices, you gain the most flexibility with the least amount of effort.

    On a side note, many implementations I have seen break out the contracts for the repositories and domain services into its own project. This is purely an organizational decision though. It is perfectly valid to have them within your domain model project.

提交回复
热议问题