跳至主要内容

博文

目前显示的是 三月, 2014的博文

ImplDDD 阅读笔记 - Domains, Subdomains and Bounded Contexts

从广义的角度来说,Domain 指的是一个组织所从事的【领域】。不同行业的组织有着截然不同的领域,它们的认知范围和运营方式构成了自身的 domain。在设计的时候,应当尽可能的将不同的 domain 分离开来,形成 Core Domain、Supporting Domain 和 Generic Domain。 + A Core Domain is a part of the business Domain that is of primary importance to the success of the organization. + 有时候为了支撑业务的运行,必须要创建 Bounded Context 来建立不可缺的模型,这就是 Supporting Subdomain。这些模型是不可缺的 (essential) 但并非最为核心的 (core)。 + 另外,对于业务而言并不具有特殊性但是对于全局 (overall business solution) 而言是必须的部分可以被归入 Generic Subdomain。 书中给出的一个例子是 SaaSOviation 的 collaboration product,在设计的时候,这个虚拟的团队一开始将 `User` 和 `Permission` 这样的 domain 融入了 `Forum`、`Discussion` 之中,导致了不必要的概念引入,从而形成了不必要的 complicated code: public class Forum extends Entity { public Discussion startDiscussion(String aUsername, String aSubject) { if (this.isClosed()) { throw new IllegalStateException("Forum is closed."); } User user = userRepository.userFor(this.tenantId(), aUsername); if (...