わからないことはわからんと言う

日々のわからないことについて考え、それでわからなければわからんと言うブログ

DDDの文脈におけるドメインとサブドメインの関係を考える

要約

わかっていなかったこと

理解できるように参考にしたもの

ドメインとは

まずは、DDDにおけるドメインについて把握しておこう。

実践ドメイン駆動設計では、以下のように記載されている。

ドメインとは、組織が行う事業やそれを取り巻く世界のことだ。

実践ドメイン駆動設計 p41

Learning Domain-Driven Design(以下、Learning DDD)では以下のように記載されている。

A business domain defines a company’s main area of activity.

上記より、ドメインとは企業の主要なビジネス活動を行う領域のことだと解釈した。 特に、Learning DDDではbuisiness domeinという様に、buisinessとの関係を明示していることに気がついた。 個人的には、Learning DDDでされていたされていた説明がかなりしっくりきたので、今後はビジネスドメインと口にしていきたい。

また、Learning DDDで重要な点として以下が記載されていた。Nokiaってこんなにビジネスドメインが変わってきたのか〜と感じつつ、 ここまでビジネスドメインが変わると、ソフトウェアエンジニアもビジネスドメインについてたくさん学習しないといけないので、 ビジネス側の人たちとコミュニケーションをとった方が、効率的にビジネスドメインについての知識が蓄積されるのかな。とも思った。

It’s important to note that companies may change their business domains often. A canonical example of this is Nokia, which over the years has operated in fields as diverse as wood processing, rubber manufacturing, telecommunications, and mobile communications.

サブドメインとは

実践ドメイン駆動設計に記載されていた以下の内容が、サブドメインドメインの関係を表していると感じた。

複数のサブドメインを組み合わせて、組織の全てのドメインを作り上げることになる。

実践ドメイン駆動設計 p42

Learning DDDでは以下の様に記載されていた。Learning DDDの回し者みたいになってしまうのだが、説明が明快だなと感じる。 もしかしたら、Learning DDDは英語で読んでいるため、言語的特性(?)で説明が明快だと感じているだけかもしれないが。

To achieve its business domain’s goals and targets, a company has to operate in multiple subdomains. A subdomain is a fine-grained area of business activity. All of a company’s subdomains form its business domain:

また、以下の様にも記載されているように、サブドメインは、ビジネスドメインにおける目標を達成するために、相互にやりとりするということがわかる。 スターバックスの例は、すごくわかりやすかった。

The subdomains have to interact with each other to achieve the company’s goals in its business domain. For example, Starbucks may be most recognized for its coffee, but building a successful coffeehouse chain requires more than just knowing how to make great coffee. You also have to buy or rent real estate at effective locations, hire personnel, and manage finances, among other activities.

そして、サブドメインには、コアドメイン、汎用サブドメイン、支援サブドメインという3つの種類があることがわかる。 実践ドメイン駆動設計には以下の様に記載されている。

そこにはコアドメインと名付けられたサブドメインがある。

実践ドメイン駆動設計 p48

図2-2には、それ以外に二種類のサブドメインがある。支援サブドメインと汎用サブドメインだ。

実践ドメイン駆動設計 p48

見落としているかもだが、青い本はコアドメインと汎用サブドメインしか記載されていないかな??

コア(サブ)ドメインとは

ドメイン駆動設計では、コアドメインについて以下の様に記載されている。

競合時に優位に立つために、設計の一部の側面を秘密にしておく必要があるなら、それがコアドメインだ。

ドメイン駆動設計 p411

実践ドメイン駆動設計ではこうだ。

コアドメインとは業務ドメインの一部で、組織を成功に導くために最も重要なものだ。戦略的な意味において、そのコアドメインでは他を圧倒しているに違いない。

実践ドメイン駆動設計 p49

Learning DDDでは以下のように記載されている。Learning DDDでは、コアドメインサブドメインの1種類ということで、 core subdomainと記載していて、いいねと思った。

A core subdomain is what a company does differently from its competitors.

上記の引用文から解釈するに、コアドメインは、企業が競合優位性を生み出すための領域だと解釈できるのかな。 コアドメインに集中してリソースを投入すべき理由がわかった。

汎用サブドメインとは

ドメイン駆動設計では以下のように記載されている。

紛れもなくドメインモデルの一部なのだが、相当数のビジネスで必要になると思われる概念を抽象化している。例えば、輸送場、銀行業、製造業などビジネスが多様であっても、何らかのかたちで企業の組織図は必要になる。

ドメイン駆動設計 p414

Learning DDDでは以下の様に記載されている。

Generic subdomains are business activities that all companies are performing in the same way. Like core subdomains, generic subdomains are generally complex and hard to implement. However, generic subdomains do not provide any competitive edge for the company.

上記から、汎用サブドメインは、多くの企業で共通に行われている領域で、複雑で実装は大変な領域だが、企業に競争力を授けるものではない。と解釈しておく。

支援サブドメインとは

Learning DDDでは以下の様に記載されている。

As the name suggests, supporting subdomains support the company’s business. However, contrary to core subdomains, supporting subdomains do not provide any competitive advantage.

具体例も挙げられている。

For example, consider an online advertising company whose core subdomains include matching ads to visitors, optimizing the ads’ effectiveness, and minimizing the cost of ad space. However, to achieve success in these areas, the company needs to catalog its creative materials. The way the company stores and indexes its physical creative materials, such as banners and landing pages, does not impact its profits. There is nothing to invent or optimize in that area. On the other hand, the creative catalog is essential for implementing the company’s advertising management and serving systems. That makes the content cataloging solution one of the company’s supporting subdomains.

支援サブドメインはシンプルで、企業に競合優位性をもたらすものではないことがわかる。

Supporting subdomains are simple. Their business logic resembles mostly data entry screens and ETL (extract, transform, load) operations; that is, the so-called CRUD (create, read, update, and delete) interfaces. These activity areas do not provide any competitive advantage for the company, and therefore do not require high entry barriers.

汎用サブドメインと支援サブドメインの違いは、その領域が複雑かどうかかな〜。まだ、自分の中では言葉が分離できていない気がする。 どちらも、競合優位性を生み出す領域ではないということがわかった。

まとめ

DDDの文脈におけるドメインは、企業の主要なビジネス活動をする領域ということがわかった。 サブドメインは3つあり、コアドメインは、企業が競合優位性を生み出し、目標を達成するために重要な領域として捉えることがわかった。

まだわかっていないこと