← 返回刚才阅读的位置

知识卡片

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

机制接口使核心模型能声明式表达场景

理解等级:高级

战略提炼的目标是让核心活动的意义容易看见。通用子域减少非核心内容,内聚机制封装复杂运算;两者经意图清晰的接口、断言与无副作用函数支持核心模型说出“要什么”。

更深的收益来自核心模型自身形成可组合的领域语言,让客户端代码简洁地表达重要场景。声明式风格依赖清楚的概念及其约束,不能只把繁复函数换成好听的名称;剩余非核心内容也未必都能被这两种结构安置。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第15章|Cohesive Mechanisms · 查看原书依据

      COHESIVE MECHANISMS are by far most useful when they provide access through an INTENTION-REVEALING INTERFACE, with conceptually coherent ASSERTIONS and SIDE-EFFECT-FREE FUNCTIONS. MECHANISMS and supple designs allow the CORE DOMAIN to make meaningful statements rather than calling obscure functions. But an exceptional payoff comes when part of the CORE DOMAIN itself breaks through to a deep model and starts to function as a language that can express the most important application scenarios flexibly and concisely. A deep model often comes with a corresponding supple design. When a supple design reaches maturity, it provides an easily understood set of elements that can be combined unambiguously to accomplish complex tasks or express complex information, just as words are combined into sentences. At that point, client code takes on a declarative style and can be much more distilled. Factoring out GENERIC SUBDOMAINS reduces clutter, and COHESIVE MECHANISMS serve to encapsulate complex operations. This leaves behind a more focused model, with fewer distractions that add no particular value to the way users conduct their activities. But you are unlikely ever to find good homes for everything in the domain model that is not CORE.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第122章《Cohesive Mechanisms》(源文件:_epub-src/0321125215_ch15lev1sec6.html;单元03) - 结论依据:原文把机制的意图接口、断言和无副作用函数与成熟深模型的声明式客户端表达相连,并承认并非所有外围内容都有合适归宿。 - 原始内容:COHESIVE MECHANISMS are by far most useful when they provide access through an INTENTION-REVEALING INTERFACE, with conceptually coherent ASSERTIONS and SIDE-EFFECT-FREE FUNCTIONS. MECHANISMS and supple designs allow the CORE DOMAIN to make meaningful statements rather than calling obscure functions. But an exceptional payoff comes when part of the CORE DOMAIN itself breaks through to a deep model and starts to function as a language that can express the most important application scenarios flexibly and concisely. A deep model often comes with a corresponding supple design. When a supple design reaches maturity, it provides an easily understood set of elements that can be combined unambiguously to accomplish complex tasks or express complex information, just as words are combined into sentences. At that point, client code takes on a declarative style and can be much more distilled. Factoring out GENERIC SUBDOMAINS reduces clutter, and COHESIVE MECHANISMS serve to encapsulate complex operations. This leaves behind a more focused model, with fewer distractions that add no particular value to the way users conduct their activities. But you are unlikely ever to find good homes for everything in the domain model that is not CORE. - 转录说明:原 EPUB 普通首字母与后续强调标签造成的 `C OHESIVE`、`M ECHANISMS` 断词,以及术语前空格均已规范转录;此处原文三段相邻,没有省文。