将域模型、BAL 和接口拆分到单独的项目中而不是合并到一个名为 Core 的项目中的好处
Benefits of splitting out Domain Models, BAL, and Interfaces into separate projects rather just merged into one project called Core
我目前使用的架构只有 3 层:
*TestProj.Api
*TestProj.Core
-Models
Customer.cs
-Services
CustomerService.cs
-Interfaces
-Repositories
ICustomerRepository.cs
-Services
ICustomerService.cs
*TestProj.Data
CustomerRepository.cs
BaseRepository.cs
我认为将域模型和每个接口都放在核心项目中是一件好事。我还想为什么不把包含所有业务逻辑的服务放在核心内部,因为业务逻辑在技术上是域的一部分,如果不采用贫血域模型方法,甚至可以在域模型中。
我对这个架构非常满意,但是我想知道我是否可以从摆脱核心和创建项目中获益:TestProj.Services 和 TestProj.Domain 并将接口放在与其实际 类 相同的项目(例如:ICustomerRepository 现在与 CustomerRepository 在 TestProj.Data 中,ICustomerService 现在与 CustomerService 在 TestProj.Services 中。
有趣的问题。假设,您的域模型和数据模型是相同的对象。首先,我可以先提出以下设置吗
TestProj.Api
TestProj.Domain.Models
-Customer.cs
TestProj.Domain.Services
-ICustomerService.cs
TestProj.Domain.Services.Implementations
-CustomerSerice.cs (implements, IcustomerService, Depends on ICustomerRepository)
TestProj.Data
-ICustomerRepository.cs
-BaseRepository.cs
TestProj.Data.EntityFramework
-EfCustomerRepository.cs(Implements ICustomerRepository)
TestProj.Data.UsingSomeOtherORM
-OtherOrmCustomerRepository.cs(Implements ICustomerRepository)
Principles Followed are
- 每个项目都可以引用Domain.Models,但Domain.Data不引用其他项目(目标)
- 将契约(接口)与实现分开。
- 应该能够改变实现/反转依赖关系
为-
I would like to know if I could gain from getting rid of core and
creating projects
您获得的主要内容是依赖倒置和一种将解决方案拆分为非常 tiny/Independently 可测试项目的方法。如果需要,为您的业务逻辑(服务)和数据层提供不同的实现也很棒。
希望对您有所帮助!
我目前使用的架构只有 3 层:
*TestProj.Api
*TestProj.Core
-Models
Customer.cs
-Services
CustomerService.cs
-Interfaces
-Repositories
ICustomerRepository.cs
-Services
ICustomerService.cs
*TestProj.Data
CustomerRepository.cs
BaseRepository.cs
我认为将域模型和每个接口都放在核心项目中是一件好事。我还想为什么不把包含所有业务逻辑的服务放在核心内部,因为业务逻辑在技术上是域的一部分,如果不采用贫血域模型方法,甚至可以在域模型中。
我对这个架构非常满意,但是我想知道我是否可以从摆脱核心和创建项目中获益:TestProj.Services 和 TestProj.Domain 并将接口放在与其实际 类 相同的项目(例如:ICustomerRepository 现在与 CustomerRepository 在 TestProj.Data 中,ICustomerService 现在与 CustomerService 在 TestProj.Services 中。
有趣的问题。假设,您的域模型和数据模型是相同的对象。首先,我可以先提出以下设置吗
TestProj.Api
TestProj.Domain.Models
-Customer.cs
TestProj.Domain.Services
-ICustomerService.cs
TestProj.Domain.Services.Implementations
-CustomerSerice.cs (implements, IcustomerService, Depends on ICustomerRepository)
TestProj.Data
-ICustomerRepository.cs
-BaseRepository.cs
TestProj.Data.EntityFramework
-EfCustomerRepository.cs(Implements ICustomerRepository)
TestProj.Data.UsingSomeOtherORM
-OtherOrmCustomerRepository.cs(Implements ICustomerRepository)
Principles Followed are
- 每个项目都可以引用Domain.Models,但Domain.Data不引用其他项目(目标)
- 将契约(接口)与实现分开。
- 应该能够改变实现/反转依赖关系
为-
I would like to know if I could gain from getting rid of core and creating projects
您获得的主要内容是依赖倒置和一种将解决方案拆分为非常 tiny/Independently 可测试项目的方法。如果需要,为您的业务逻辑(服务)和数据层提供不同的实现也很棒。
希望对您有所帮助!