知识卡片

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

策略选择者承担模型知识

理解等级:高级

抽出策略能降低主体服务内的条件分支,但调用方必须知道该选哪种策略;这项知识不能因引入模式而消失。在领域层,应明确谁依据业务场景选政策,以及选择错误会怎样改变结果。

策略对象也增加对象数量;若实现开销确实成问题,可考虑共享无状态实例。原书把这两点分别列为建模关注与实现关注,提醒读者借用领域概念时仍须继承技术模式的代价。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第12章|Strategy (A.K.A.Policy) · 查看原书依据

      The consequences of the design pattern fully apply. For example, in Design Patterns, Gamma et al. point out that clients must be aware of different STRATEGIES, which is also a modeling concern. A concern purely of implementation is that STRATEGIES can increase the number of objects in the application. If that is a problem, the overhead can be reduced by implementing STRATEGIES as stateless objects that contexts can share.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第88章《Strategy (A.K.A.Policy)》(源文件:_epub-src/0321125215_ch12lev1sec1.html;单元02) - 结论依据:原文明确指出客户端须了解不同策略,这是建模关切;策略增加对象数量,无状态共享可减轻实现开销。 - 原始内容:The consequences of the design pattern fully apply. For example, in Design Patterns , Gamma et al. point out that clients must be aware of different STRATEGIES , which is also a modeling concern. A concern purely of implementation is that STRATEGIES can increase the number of objects in the application. If that is a problem, the overhead can be reduced by implementing STRATEGIES as stateless objects that contexts can share.