知识卡片
声明驱动行为减少样板代码
声明式设计把模型属性写成可执行的精确说明,让程序行为由声明控制,例如由反射机制解释声明,或在编译时按声明生成常规代码。它能省去反复手写的样板流程,使读者在框架确实覆盖且执行的部分可按声明理解行为。
原书所说的“保证”有前提:手写代码、额外副作用或绕开框架的路径仍可能偏离声明,不能把局部约束扩成整个系统的形式化正确性。参见[[断言明确状态契约]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第10章|Declarative Design · 查看原书依据
These are some of the motivations behind declarative design. This term means many things to many people, but usually it indicates a way to write a program, or some part of a program, as a kind of executable specification. A very precise description of properties actually controls the software. In its various forms, this could be done through a reflection mechanism or at compile time through code generation (producing conventional code automatically, based on the declaration).
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第79章《Declarative Design》(源文件:_epub-src/0321125215_ch10lev1sec7_split_000.html;单元01)
- 结论依据:原文把声明式设计定义为以精确属性说明控制软件,并列出反射与编译期生成两种实现;前文承认手写过程与未排除副作用无法得到同样保证。
- 原始内容:These are some of the motivations behind declarative design . This term means many things to many people, but usually it indicates a way to write a program, or some part of a program, as a kind of executable specification. A very precise description of properties actually controls the software. In its various forms, this could be done through a reflection mechanism or at compile time through code generation (producing conventional code automatically, based on the declaration).