返回主题:契约式设计

此卡片不在当前主题的阅读序列中,可返回主题继续阅读。

知识卡片

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

规格统一验证查询与按需生成

理解等级:中级

Specification 描述对象应满足的条件,书中归纳三种用途:

  1. 验证已有对象。
  2. 从集合中筛选对象。
  3. 规定按需创建的新对象应满足什么条件。

三者在概念上共用同一规则,具体实现可不同;保持一个业务含义,能减少同一规则散落成互相矛盾的版本。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第70章《How to Model Less Obvious Kinds of Concepts》,Applying and Implementing Specification(源文件:_epub-src/0321125215_ch09lev1sec2_split_000.html) - 结论依据:原文直接列出验证、选择和按需生成三类用途,并说明概念统一性。 - 原始内容:Much of the value of SPECIFICATION is that it unifies application functionality that may seem quite different. We might need to specify the state of an object for one or more of these three purposes. To validate an object to see if it fulfills some need or is ready for some purpose To select an object from a collection (as in the case of querying for overdue invoices) To specify the creation of a new object to fit some need These three uses—validation, selection, and building to order—are the same on a conceptual level. Without a pattern such as SPECIFICATION , the same rule may show up in different guises, and possibly contradictory forms. The conceptual unity can be lost. Applying the SPECIFICATION pattern allows a consistent model to be used, even when the implementation may have to diverge. - 转录说明:三项用途是原书列表,EPUB 文本抽取使列表项连续显示;原 EPUB 将两处破折号编码为异常字符,上引规范转录。