知识卡片
夜间批处理只负责编排
原书的虚构贷款系统对话中,夜间批处理原本藏有过账业务逻辑。开发者没有采用即时触发:计提由批处理发起,而付款白天也会录入;让规则时机紧贴批处理会增加耦合。改用 Posting Rule 主导的延迟触发,由批处理发起执行、规则寻找适用的新条目。
改造后的批处理遍历 Asset,发送表达意图的消息并提交数据库事务;计提与过账选择转入领域对象。Posting Service 是对遗留会计 API 的门面。书中叙述的是案例设计结果,未提供运行性能或故障率的实测结果。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第11章|Example Insight into the Nightly Batch · 查看原书依据
Over the next few days, the two developers worked out a model and refactored the code so that the batch simply iterated through the Assets, sending a few self-explanatory messages to each and then committing the database transactions. The complexity was shifted into the domain layer, where an object model made it both more explicit and more abstract.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第85章《Example Insight into the Nightly Batch》(源文件:_epub-src/0321125215_ch11lev2sec2.html;单元02)
- 结论依据:对话排除eager firing并选Posting-Rule-based firing;图11.9–11.11及段落说明批处理迭代Asset、领域层承接复杂逻辑。
- 原始内容:Over the next few days, the two developers worked out a model and refactored the code so that the batch simply iterated through the Assets , sending a few self-explanatory messages to each and then committing the database transactions. The complexity was shifted into the domain layer, where an object model made it both more explicit and more abstract.