知识卡片

结构图卡 · 1971.o.1.b.1.a.2.c.1.b.2.a

共享内核只共享双方必需的模型子集

理解等级:高级

两个团队各有自己的限界上下文,却有部分领域概念必须共同维护时,可以明确划出共享内核:双方同意共享的一小部分领域模型,连同对应代码或数据库设计。它不是把整个上下文重新合并;内核之外仍可独立演化,必要时用翻译衔接。

共享范围要谨慎选择。过大使跨团队协调成本接近整套模型的持续集成;过小则会重复实现,并在日后付出更多翻译与适配成本。原书图示的重叠区代表被双方共同承认的共享部分;下图以无向连接表示两个上下文共同维护一块交集,不表示单向依赖。

结构图:

flowchart LR
 A[上下文 A 的非共享部分] --- K((共享内核:双方同意的交集))
 K --- B[上下文 B 的非共享部分]
 A <-.必要时经翻译映射交互.-> B
这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第14章|Shared Kernel · 查看原书依据

      Designate some subset of the domain model that the two teams agree to share. Of course this includes, along with this subset of the model, the subset of code or of the database design associated with that part of the model. This explicitly shared stuff has special status, and shouldn't be changed without consultation with the other team.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第105章《Shared Kernel》(源文件:_epub-src/0321125215_ch14lev1sec5.html;单元01) - 结论依据:原文定义共享模型、代码和数据库的子集,并说明目的在降低重复而非完全消除。 - 原始内容:Designate some subset of the domain model that the two teams agree to share. Of course this includes, along with this subset of the model, the subset of code or of the database design associated with that part of the model. This explicitly shared stuff has special status, and shouldn't be changed without consultation with the other team.