知识卡片
可组合接口呈现声明式风格
客户代码不一定要换成独立的领域语言,才有声明式表达。若接口名称直接传达领域意图,函数无可观察副作用,命令的状态效果由断言说清,调用者就能把这些可组合单元写成接近业务规则的语句。
这种“声明式风格”仍由常规代码执行,不等于框架已从模型声明自动生成程序,也不因此获得整个系统的形式化保证。参见[[声明驱动行为减少样板代码]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第10章|A Declarative Style of Design · 查看原书依据
Once your design has INTENTION-REVEALING INTERFACES, SIDE-EFFECT-FREE FUNCTIONS, and ASSERTIONS, you are edging into declarative territory. Many of the benefits of declarative design are obtained once you have combinable elements that communicate their meaning, and have characterized or obvious effects, or no observable effects at all.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第81章《A Declarative Style of Design》(源文件:_epub-src/0321125215_ch10lev1sec8.html;单元01)
- 结论依据:原文明确说意图揭示接口、无副作用函数和断言使设计接近声明式领域,许多收益来自含义与效果明确的可组合元素。
- 原始内容:Once your design has INTENTION-REVEALING INTERFACES , SIDE-EFFECT-FREE FUNCTIONS , and ASSERTIONS , you are edging into declarative territory. Many of the benefits of declarative design are obtained once you have combinable elements that communicate their meaning, and have characterized or obvious effects, or no observable effects at all.