Domain Driven Design and the role of the factory class

后端 未结 6 1798
温柔的废话
温柔的废话 2021-01-29 18:33

I\'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (agg

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 19:07

    Probably at my own peril, I tend not to emphasize design patterns unless i'm really stuck. I just build the system as I think of it and refactor until it makes some sense the following day.

    I use a factory when:

    • Some layer needs to create an object with some regularity. and
    • Only that layer knows when to create it, or with what customisations and
    • Only some other layer knows exactly what to create.

提交回复
热议问题