知识卡片
原始字段跨系统也可能语义不同
跨系统交换“原始字段”时,字段名和值看似相同,关联规则和约束仍可能不同。若新系统直接按自己的意义解释旧系统字段,轻则业务对象失真,重则可能写坏数据。
低层字段接口还把外部模型的解释责任推给本地调用方,使双方语义混在一起。设计防腐层时,应先识别每个字段在原模型中的含义与关系,再翻译为本地概念。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第14章|Anticorruption Layer · 查看原书依据
A low-level interface takes away the power of the other system's model to explain the data and constrain its values and relationships, while saddling the new system with the burden of interpreting primitive data that is not in terms of its own model.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第109章《Anticorruption Layer》(源文件:_epub-src/0321125215_ch14lev1sec8.html;单元01)
- 结论依据:原文指出原始数据语义并不天然一致,低层接口失去外部模型解释及约束数据的能力。
- 原始内容:It seems clear enough that errors will result if you take some data from one system and misinterpret it in another. You may even corrupt the database. [...] This assumption is usually wrong. Subtle yet important differences in meaning arise from the way the data are associated in each system. And even if primitive data elements do have exactly the same meaning, it is usually a mistake to make the interface to the other system operate at such a low level. A low-level interface takes away the power of the other system's model to explain the data and constrain its values and relationships, while saddling the new system with the burden of interpreting primitive data that is not in terms of its own model.