← 返回刚才阅读的位置

知识卡片

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

同名概念跨模型不能直接复用

理解等级:高级

两个团队都叫 Charge,不代表对象有相同含义。原书作者回忆的项目中,客户开票组复用供应商付款组的 Charge,并补字段;代码暂时能运行,后来付款模块出现异常记录,月度抵扣税额计算甚至崩溃。根因是两组对 Charge 的假设不同,却未识别模型边界。

复用前应核对概念、规则和数据约束是否一致;若无法统一,就显式保留各自模型并定义关系。作者当时最终拆成 Customer Charge 和 Supplier Charge,但并未由此建立长期检测过程。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter Fourteen. Maintaining Model Integrity · 查看原书依据

      The problem was that these two groups had different models, but they did not realize it, and there were no processes in place to detect it. Each made assumptions about the nature of a charge that were useful in their context (billing customers versus paying vendors). When their code was combined without resolving these contradictions, the result was unreliable software.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第99章《Chapter Fourteen. Maintaining Model Integrity》(源文件:_epub-src/0321125215_ch14.html;单元01) - 结论依据:原文亲历案例说明两组Charge模型含义不同、无检测过程导致混用后不可靠,随后拆出两个类但未持续治理。 - 原始内容:The problem was that these two groups had different models , but they did not realize it, and there were no processes in place to detect it. Each made assumptions about the nature of a charge that were useful in their context (billing customers versus paying vendors). When their code was combined without resolving these contradictions, the result was unreliable software.