← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1971.o.1.b.4.d.1.c.1.b.8.a

细分规则归知道规则的对象

理解等级:中级

货物具有起终点等数据,却不宜因此让 Cargo 自行推导 Enterprise Segment。原书中同一货物可按订舱配额或税务目的被不同方式细分,销售策略调整也会改变配额细分规则;若规则放进 Cargo,它就得认识 Allocation Checker 并承载多套目的特定方法。职责应归知道细分规则的对象。把规则再拆成可传入的 Strategy 是作者提出的后续可选设计,当前案例尚无此需求。参见[[企业细分把货物类别提升为领域概念]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第07章|A Final Look · 查看原书依据

      Therefore, the responsibility for deriving this value lies properly with the object that knows the rules for segmentation, rather than the object that has the data to which those rules apply. Those rules could be split out into a separate "Strategy" object, which could be passed to a Cargo to allow it to derive an Enterprise Segment.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第60章《原书第07章|A Final Look》(源文件:_epub-src/0321125215_ch07lev1sec12.html) - 结论依据:原文以同一货物的多种细分目的和销售策略变化说明 Cargo 不应承担细分规则,规则归属应由知识所在决定。 - 原始内容:Therefore, the responsibility for deriving this value lies properly with the object that knows the rules for segmentation, rather than the object that has the data to which those rules apply. Those rules could be split out into a separate " Strategy " object, which could be passed to a Cargo to allow it to derive an Enterprise Segment .