Open3

Domain-Driven Design with Golangの読書メモ

nabetsunabetsu

Part1: Introduction to Domain-Driven Design

Chapter1: A Brief History of Domain-Driven Design

The World Before DD

  • ソフトウェアの複雑さが増すごとに現実世界のモデルとモデル化したシステムの差が広がっていった

a great deal of domain-driven design comes straight out of good old-fashioned object-oriented design patterns.” (Evans, in an interview with Software Engineering Radio, 2019, Episode 8: https://youtu.be/7yUONWp-CxM)

  • object-oriented design (OOD) patternsにインスピレーションを受けている
  • Design Patterns, Elements of Reusable Object-Oriented Softwareで紹介されている23のデザインパターン
  • 上記の本は以下の3つのセクションに分かれており、これを知ることはDDDを知る上でも重要
  • Creational patterns are patterns concerned with creating objects instead of creating objects directly. This gives more flexibility to the program in deciding which object type to create, given the current context.
  • Structural patterns are concerned with how you compose objects within your program to achieve certain functionality.
  • Behavioral patterns are concerned with how objects communicate.

Eric Evans and DDD

One reason is that the book outlined three pillars that can be used independently or together to improve complex software projects.

  • Ubiquitous language
    • ドメインについて話すための共通言語。ドメインエキスパートから教えてもらってはならない。
  • Strategic design
    • DDDのプロセスでbusiness domainとbounded contextsを定義するためのもの
  • Tactical design
    • システムが具体的にどのようになるべきかを設計するフェーズ
    • entities, aggregates, values objectsとかはここで出てくる

When should you use DDD?

DDDは巨大で複雑なシステムに適用した時に最も効果を発揮する。
シンプルなCRUDのアプリに適用しても逆に複雑さをもたらすだけになるので、適用に一定の基準はあったほうが良い

nabetsunabetsu

Part1: Introduction to Domain-Driven Design

Chapter2: Understanding Domains, Ubiquitous Language, and Bounded Contexts

条件設定

  • payments and subscriptions teaに配属
  • lean(見込み客?)がアプリを使う時、最初にsubscription planを選ぶ
  • planにはbasic, premium, exclusiveの3つがある
  • 選択したプランに応じて利用可能な機能が異なる
  • プランが作成された時点で、leadはcustomerに変わる
  • churnすると再びleadにあり、その状態が6ヶ月続くとlost leadになる
  • lost leadはreengagement campaignの対象になり、discount codeが発行される
  • planが作成されると繰返しの支払い(recurring payment)が設定される