知识卡片

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

领域语言贴近模型但需可演进

理解等级:高级

领域专用语言(DSL)把特定领域模型的词汇和组合语法做成编程语言。原书的运输系统教学例子用 cargo、route 等词编写客户代码,再编译到由类库实现的常规面向对象代码;这种表达可接近团队的通用语言。

若模型演进,团队可能同时要改语法声明、解释机制、底层类库及已有客户代码。采用前应评估当前与未来维护团队的技能,以及重构旧程序的成本;DSL 有时是声明式设计的一种,并非只要有领域词汇就自动获得声明式保证。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

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

      An interesting approach that is sometimes declarative is the domain-specific language. In this style, client code is written in a programming language tailored to a particular model of a particular domain. For example, a language for shipping systems might include terms such as cargo and route, along with syntax for associating them. The program is then compiled, often into a conventional object-oriented language, where a library of classes provides implementations for the terms in the language.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第79章《Declarative Design》(源文件:_epub-src/0321125215_ch10lev1sec7_split_000.html;单元02) - 结论依据:原文说明 DSL 的领域词汇、编译与类库实现路径,同时指出模型变化时语言和客户代码可能难以同步重构。 - 原始内容:An interesting approach that is sometimes declarative is the domain-specific language. In this style, client code is written in a programming language tailored to a particular model of a particular domain. For example, a language for shipping systems might include terms such as cargo and route , along with syntax for associating them. The program is then compiled, often into a conventional object-oriented language, where a library of classes provides implementations for the terms in the language.