知识卡片
领域服务封装中粒度能力
把需要多个细粒度领域对象协作的能力封装成中粒度、无状态的[[领域服务承载独立动作]],能让调用方通过较简单的接口完成业务任务,减少应用层自行编排而泄漏领域知识;在分布式系统中也可减少过细的消息交互。代价是调用方对内部步骤的控制和灵活性下降,因此应按真实业务边界决定粒度,而非把所有对象操作统一包成服务。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第05章|Services · 查看原书依据
Medium-grained, stateless SERVICES can be easier to reuse in large systems because they encapsulate significant functionality behind a simple interface. Also, fine-grained objects can lead to inefficient messaging in a distributed system.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第40章《原书第05章|Services》(源文件:_epub-src/0321125215_ch05lev1sec4.html)
- 结论依据:原文将中粒度服务的简单接口、细粒度交互导致的消息与领域知识泄漏,以及接口简洁和调用方控制之间的取舍放在一起讨论。
- 原始内容:Medium-grained, stateless SERVICES can be easier to reuse in large systems because they encapsulate significant functionality behind a simple interface. Also, fine-grained objects can lead to inefficient messaging in a distributed system. ... The complexity of a highly detailed interaction ends up being handled in the application layer, allowing domain knowledge to creep into the application or user interface code, where it is lost from the domain layer. ... This pattern favors interface simplicity over client control and versatility.