知识卡片

普通读书笔记卡 · 1971.o.1.b.4.d.1.c.4.b

工厂隔离复杂创建职责

理解等级:中级

复杂对象或整个聚合的装配若放在产品自身,会混入其运行期职责;若交给调用方,调用方必须知道内部结构、规则和具体类,甚至把领域职责泄漏到应用层。工厂负责封装这段创建知识,以符合调用方目标的接口交付产品。工厂通常是领域设计中的实现构件,不一定是领域模型中的业务概念;原书以“开户”说明创建有时本身具有业务意义。参见[[对象生命周期由三类模式协作]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第45章《原书第06章|Factories》(源文件:_epub-src/0321125215_ch06lev1sec2.html;图6.12) - 结论依据:原文分别分析产品自建和客户端装配的职责及耦合问题,定义工厂为负责创建其他对象的程序构件,并区分领域设计构件与模型概念。 - 原始内容:We are adding elements to the design that do not correspond to anything in the model, but they are nonetheless part of the domain layer's responsibility. ... A program element whose responsibility is the creation of other objects is called a FACTORY .