知识卡片
交付目标变更可替换值对象
原书货运案例中,客户改了货物目的地;Delivery Specification 是值对象,Cargo 可用新的规格整体替换旧规格,无需修改旧规格的内部属性。这让当前交付目标随货物更新,已发生的交付历史仍是另一份事实记录。这里是原书示例中的简单变更路径,具体授权、在途约束与操作后果未在本节规定。参见[[交付规格独立表达货物目标]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第07章|Walking Through Scenarios · 查看原书依据
Delivery Specification is a VALUE OBJECT, so it would be simplest to just to throw it away and get a new one, then use a setter method on Cargo to replace the old one with the new one.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第55章《原书第07章|Walking Through Scenarios》(源文件:_epub-src/0321125215_ch07lev1sec7.html)
- 结论依据:原文用客户更改目的地的应用场景说明,交付规格是值对象,可丢弃旧值、生成新值并在 Cargo 上替换。
- 原始内容:Delivery Specification is a VALUE OBJECT , so it would be simplest to just to throw it away and get a new one, then use a setter method on Cargo to replace the old one with the new one.