← 返回刚才阅读的位置

知识卡片

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

声明框架受限会侵蚀保证

理解等级:高级

声明式保证只覆盖确由声明控制的行为。原书列出几种失效路径:

  1. 声明语言表达不了必要逻辑,框架又难扩展,团队被迫压低模型和功能。
  2. 生成代码混入手写代码,使重生成破坏已有修改,削弱迭代重构。
  3. 规则系统为性能加入控制谓词,引入副作用;增删或重排规则后结果可能改变。

选择框架时,应核对表达范围、再生成过程及绕过规则的路径。原书的经验性判断是:范围较窄、专门自动化持久化等繁琐易错工作,同时保留建模自由的框架,收益较可靠;这不是所有框架的实测排名。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第10章|Declarative Design · 查看原书依据

      Although a rules-based program is declarative in principle, most systems have "control predicates" that were added to allow performance tuning. This control code introduces side effects, so that the behavior is no longer dictated completely by the declared rules. Adding, removing, or reordering the rules can cause unexpected, incorrect results. Therefore, a logic programmer has to be careful to keep the effect of code obvious, just as an object programmer does.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第79章《Declarative Design》(源文件:_epub-src/0321125215_ch10lev1sec7_split_000.html;单元01) - 结论依据:原文先列声明语言受限、生成代码破坏迭代两类问题,再说明规则系统中的控制谓词会引入副作用,规则顺序变化可产生意外结果。 - 原始内容:Although a rules-based program is declarative in principle, most systems have "control predicates" that were added to allow performance tuning. This control code introduces side effects, so that the behavior is no longer dictated completely by the declared rules. Adding, removing, or reordering the rules can cause unexpected, incorrect results. Therefore, a logic programmer has to be careful to keep the effect of code obvious, just as an object programmer does.