知识卡片
可运行原型须声明算法与回滚局限
原书假设的 PrototypePacker 顺序寻找第一个能容纳桶的容器,可先打通应用到服务的反馈链路;它遵守已声明的安全约束,却可能先把沙子放进专用容器,导致后续危险品无处可放,也不优化收益。代码还注明抛异常时容器可能已改变,回滚须由上层处理。它是教学原型,不能当生产求解器或原子操作。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第09章|How to Model Less Obvious Kinds of Concepts · 查看原书依据
Granted that this code leaves a lot to be desired. It might pack sand into specialty containers and then run out of room before it packs the hazardous chemicals. It certainly doesn't optimize revenues. But a lot of optimization problems are never solved perfectly anyway. This implementation does follow the rules that have been stated so far.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第70章《How to Model Less Obvious Kinds of Concepts》,Example A Working Prototype of the Warehouse Packer(源文件:_epub-src/0321125215_ch09lev1sec2_split_000.html)
- 结论依据:原文承认贪心原型不保证优选,代码注释提示失败后的回滚责任。
- 原始内容:Containers' contents may have changed. Rollback must be handled at a higher level. ... Granted that this code leaves a lot to be desired. It might pack sand into specialty containers and then run out of room before it packs the hazardous chemicals. It certainly doesn't optimize revenues. But a lot of optimization problems are never solved perfectly anyway. This implementation does follow the rules that have been stated so far.