知识卡片

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

同一规格查询可有不同执行路径

理解等级:中级

筛选拖欠发票时,若少量 Invoice 已在内存,可逐个调用 isSatisfiedBy;若记录大量存于关系库,应利用数据库查询能力。领域层保持 DelinquentInvoiceSpecification 的业务含义,仓储与基础设施选择执行路径。原书并未声称内存遍历适合任何数据规模。参见[[规格统一验证查询与按需生成]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第70章《How to Model Less Obvious Kinds of Concepts》,Selection (or Querying),图9.15(源文件:_epub-src/0321125215_ch09lev1sec2_split_000.html) - 结论依据:原文说明验证与集合筛选共用规格概念,但查询实现因数据量和存储位置而变。 - 原始内容:Another common need is to select a subset of a collection of objects based on some criteria. The same concept of SPECIFICATION can be applied here, but implementation issues are different. [...] To demonstrate that the concept is the same, let's assume first that the number of Invoices is small, maybe already in memory. In this case, the straightforward implementation developed for validation still serves. [...] Of course, the Invoice objects probably aren't in memory. There may be thousands of them. In a typical business system, the data is probably in a relational database. [...] Relational databases have powerful search capabilities. How can we take advantage of that power to solve this problem efficiently while retaining the model of a SPECIFICATION ?