DDD Entities making use of Services

后端 未结 5 1438
生来不讨喜
生来不讨喜 2021-02-01 08:18

I have an application that I\'m trying to build with at least a nominally DDD-type domain model, and am struggling with a certain piece.

My entity has some business logi

5条回答
  •  孤独总比滥情好
    2021-02-01 09:16

    Have your service accept the Ticket entity as a parameter. Services should be stateless and the same service should be able to provide its services to any number of entities.

    In your situation I would pull the FinancialCalculatorService and RateCalculatorService out of your entity and make the methods on each service accept the Ticket entity as a parameter.

    Take a second and read pg. 105 of Domain-Driven Design by Eric Evans

提交回复
热议问题