What methods should go in my DDD factory class?

后端 未结 7 1387
终归单人心
终归单人心 2021-02-02 17:38

I am struggling to understand what my factory class should do in my DDD project. Yes a factory should be used for creating objects, but what exactly should it be doing. Consid

7条回答
  •  日久生厌
    2021-02-02 18:05

    @ThinkBeforeCoding - in @m4bwav's example, the factory is getting a valid ID from a helper method, but it's not creating a new record in a persistence layer anywhere. If, however, I'm using a database auto-generated identity column as my identities, it seems like a factory would have to call into the repository to do the initial object creation. Can you comment on which method is "correct"?

提交回复
热议问题