DDD - Dependencies between domain model, services and repositories

前端 未结 6 2061
旧时难觅i
旧时难觅i 2020-12-23 10:32

Just wanted to know how others have layered their architecture. Say I have my layers as follows:

Domain Layer
--Product
--ProductService (Should the imp go

6条回答
  •  难免孤独
    2020-12-23 11:09

    Your domain model shouldn't have a reference to ProductService nor to IProductRepository. If you create a new Product it has to be created through a factory - the Factory may use ProductService to get a product id.

    In fact I'd wrap ProductService with an appropriate interface, such as IProductIdGeneratorService so that you can inject this into the factory using your IoC container.

提交回复
热议问题