知识卡片

普通读书笔记卡 · 1971.o.3.a.1.b.1.a.1

工厂配置规格以隔离外部政策依赖

理解等级:中级

原书拖欠发票示例中,工厂可用客户账户或公司政策信息配置 Specification,再用固定评估日期检查 Invoice。这样 Invoice 无须直接依赖那些数据源,规则仍以领域对象呈现。该规格对象用完即弃的设计适用于示例场景。应用推断:其他规则是否缓存或复用,需按依赖与生命周期判断。参见[[规格对象让复杂业务断言留在领域层]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第70章《How to Model Less Obvious Kinds of Concepts》,Specification,图9.13(源文件:_epub-src/0321125215_ch09lev1sec2_split_000.html) - 结论依据:原文明确工厂可从其他来源配置规格,避免 Invoice 耦合非本职数据源。 - 原始内容:A FACTORY can configure a SPECIFICATION using information from other sources, such as the customer's account or the corporate policy database. Providing direct access to these sources from the Invoice would couple the objects in a way that does not relate to the request for payment (the basic responsibility of Invoice ). In this case, the Delinquent Invoice Specification was to be created, used to evaluate some Invoices , and then discarded, so a specific evaluation date was built right in—a nice simplification. - 转录说明:原 EPUB 在 `in` 与 `a nice simplification` 间以异常字符编码破折号,上引规范转录。