DDD Entities making use of Services

后端 未结 5 1380
生来不讨喜
生来不讨喜 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 08:59

    You've actually struck on a question that there has been quite a bit of discussion on. There are believers on both sides of the tracks so you need to decide for yourself what makes the most sense.

    Personally I don't have my entities use services as it creates a whole lot of work around the "How do I cleanly get services into my entities?" question.

    It looks to me like CalculateFinancialGains() is more of a service level call. This does lead to Ticket being very anemic but I assume it has other behavior? And if it doesn't that's probably a smell...

提交回复
热议问题