知识卡片
跨上下文只翻译必要方向
原书的货运预订教学例子将预订模型与运输网络模型分开。预订侧的 Route Specification 译成位置代码列表交给网络遍历服务;其返回的节点 ID 列表,再按出发/到达节点配对译成 Itinerary 的各段 Leg。翻译的是接口所需的两个方向,无需为整套模型建立双向一一映射。
反向把任意位置列表恢复成 Route Specification 可能有歧义:中间点未必能识别为海关清关点。业务不需要这个反向转换时,不应为追求形式对称而补造语义。
结构图:
flowchart LR
RS[预订上下文:路线规格] -->|约束翻译| LC[运输网络上下文:位置列表]
LC --> NS[网络遍历服务]
NS --> NN[节点 ID 列表]
NN -->|节点配对与语义翻译| IT[预订上下文:行程及航段]
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第14章|Context Map · 查看原书依据
Notice that the reverse translation would be ambiguous, because the network traversal input allows any number of intermediate points, not just one specifically designated as customs clearance point. Fortunately, this is no problem because we don't need to translate in that direction, but it gives a glimpse of why some translations are impossible.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第103章《Context Map》(源文件:_epub-src/0321125215_ch14lev1sec3.html;单元03)
- 结论依据:原文说明该案例只需两种特定翻译,并指出位置列表反向译为路线规格会有中间点语义歧义。
- 原始内容:Notice that the reverse translation would be ambiguous, because the network traversal input allows any number of intermediate points, not just one specifically designated as customs clearance point. Fortunately, this is no problem because we don't need to translate in that direction, but it gives a glimpse of why some translations are impossible.