知识卡片

普通读书笔记卡 · 1971.o.1.b.1.a.2.a.3.g.3

危险品选路规则由Router协调可守住层依赖

理解等级:高级

在原书延续的假设危险品场景中,HazMat Route Policy Service 属于 Decision Support。若让 Operations 的 Cargo 主动调用它,便形成低层依赖高层,违背既定责任层。图16.9–16.10展示这条看似自然却冲突的路径。

另一方案让 Router 收集适用政策、读取 Cargo 的危险品代码,再组合约束并选路,图16.11–16.12展示流程。原书并未断言后者局部设计绝对更好;收益在全项目保持可理解的一致性。若一致性代价持续过高,应重新评估层结构。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第130章《Responsibility Layers》(源文件:_epub-src/0321125215_ch16lev1sec3.html;单元04) - 结论依据:原文比较Cargo调用政策服务与Router收集政策两种设计,并明确前者跨层方向冲突、后者是保持整体规则的一种可能方案。 - 原始内容:There are always many design possibilities, and we'll just have to choose another one—one that follows the rules of the large-scale structure. The HazMat Route Policy Service is all right, but we need to move the responsibility for using the policy. Let's try giving the Router the responsibility for collecting appropriate policies before searching for a route. This means changing the Router interface to include objects that policies might depend on. Here is a possible design. [...] Now, this isn't necessarily a better design than the other. They both have pros and cons. - 转录说明:`—` 是原 EPUB 的异常破折号字节,原样保留;`[...]` 标明图16.11–16.12及段落间省略。