Generating identities for entities in DDD

后端 未结 2 1040
自闭症患者
自闭症患者 2021-01-02 10:11

Edit

To further clarify my initial problem, I rewrote the question with more \'DDD\'-termini, common patterns and discussion arguments. The orginal version can be

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 10:42

    I would place it in a factory. Generating id shouldn't be a part of domain logic in my opinion, because it's really an infrastructure matter. You can take id from DB or generate it with uuid or whatever. It's a detail. Also remember that only interface of a factory belongs to domain layer, not its implementation.

    About your doubts for factory, if you use factory to create entities then you should use it everywhere. This is how I do it.

提交回复
热议问题