領域驅動設計
Domain-Driven Design
服務拆分與溝通模式
領域驅動開發
Domain-Driven Design
服務拆分與溝通模式



領域驅動開發
Domain-Driven Design
服務拆分與溝通模式

https://ithelp.ithome.com.tw/m/articles/10216792
統一語言
Ubiquitous Language
業務知識與實作的橋樑
難題 1:你的商品不是我的商品
那個不知道為什麼明明是同樣的東西卻是有兩個頁面的商品
那個要拿去算成本毛利,有時賣不太出去被當成贈品包在一起賣出去的商品
那個下訂單後要記得客人退錢退多少錢的商品
那個寄到客戶家中跟客服說壞掉的那個商品
那個在倉庫逼逼驗入後要盡量放一起的那個商品
那個不知道為什麼明明是同樣的東西卻是有兩個頁面的商品
那個要拿去算成本毛利,有時賣不太出去被當成贈品包在一起賣出去的商品
那個下訂單後要記得客人退錢退多少錢的商品
那個寄到客戶家中跟客服說壞掉的那個商品
那個在倉庫逼逼驗入後要盡量放一起的那個商品
Catalog Item
Sales
Item
Order
Item
Sku
Pieces
告訴我,你說的什麼是商品?
Ubiquitous Language
統一語言
Ubiquitous Language
業務知識與實作的橋樑
統一語言
統一語言
Ubiquitous Language
業務知識與實作的橋樑
難題加碼:會員
Account (Identity)
Reciever (Order)
Payer (Payment)
Buyer, Viewer...
萃取業務邏輯:Event Storming
統一語言
Ubiquitous Language
業務知識與實作的橋樑

統一語言
Ubiquitous Language
業務知識與實作的橋樑
用程式實現:Modeling
限界上下文
Bounded Context
清楚的邊界不會攪拌在一起
難題 2:那...你改還是我改?
限界上下文
Bounded Context
清楚的邊界不會攪拌在一起

限界上下文
Bounded Context
清楚的邊界不會攪拌在一起
Autonomy 自治性

限界上下文
Bounded Context
清楚的邊界不會攪拌在一起
4+1 Architectural View Model

codebase/git
cloud infra/cd
communication
functionality
限界上下文
Bounded Context
清楚的邊界不會攪拌在一起
Dependency Direction 依賴方向
限界上下文
Bounded Context
清楚的邊界不會攪拌在一起
先知道要去哪裡
Migrate Path
限界上下文
Bounded Context
清楚的邊界不會攪拌在一起

限界上下文合作
Context Mapping
邊界認知一致的合作
難題 3:你改了要告訴我啊!
限界上下文合作
Context Mapping
邊界認知一致的合作
大泥球
Big Bud Ball
限界上下文合作
Context Mapping
邊界認知一致的合作
客戶/供應商模式
Customer/Supplier

限界上下文合作
Context Mapping
邊界認知一致的合作
共享核心
Shared Kernal

限界上下文合作
Context Mapping
邊界認知一致的合作
防腐層模式
Anti-Corruption Layer

限界上下文合作
Context Mapping
邊界認知一致的合作
追隨者模式
Conformist

限界上下文合作
Context Mapping
邊界認知一致的合作
追隨者模式
Conformist

限界上下文合作
Context Mapping
邊界認知一致的合作
公開主機模式
Open Host Service/ Published Language

限界上下文合作
Context Mapping
邊界認知一致的合作
另尋他路
Separate Way
限界上下文合作
Context Mapping
邊界認知一致的合作

限界上下文合作
Context Mapping
邊界認知一致的合作
控制權
The level of control
協作成本
The cost of coordination
限界上下文合作
Context Mapping
邊界認知一致的合作
重複和分身程式碼
Duplicated/Inconsistent Code
限界上下文合作
Context Mapping
邊界認知一致的合作
大系統 Big Context
小系統 Small Context
https://xiaoyue26.github.io/2019/07/22/2019-07/%E9%A2%86%E5%9F%9F%E9%A9%B1%E5%8A%A8%E8%AE%BE%E8%AE%A1-%E7%AC%AC7-17%E7%AB%A0%E7%AC%94%E8%AE%B0/
One Cohesive model, more clear & less transfer cost
Less abstract design required
More flexible for specific demands
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
難題 4:道理懂了,但程式怎麼寫?
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起

領域建模
Domain Modeling
清楚的邊界不會攪拌在一起

https://insights.thoughtworks.cn/tag/domain-driven-design/
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
應用服務
Application
Service
API endpoints, Controller, Protocol Resolve, Queue listeners...
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
聚合
Aggregate
Order = OrderItem + OrderPayment ...
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
實體
Entity
Item, Member
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
實體
Repository
Database/Storage Driver
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起
領域事件
Domain Event
Tell everyone what happened
Pub/Sub
領域建模
Domain Modeling
清楚的邊界不會攪拌在一起

https://www.vendia.com/blog/applying-domain-driven-design-to-blockchains
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
難題 5:程式寫好了,但隔壁棚的該怎麼串?

跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構

https://solace.com/blog/microservices-choreography-vs-orchestration/
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
CQRS
(Command and Query Responsibility Segregation)
寫入與查詢分離
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構

https://www.youtube.com/watch?v=Fso2OyguRuQ
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
gRPC
RestFul API
Pub/Sub
Data Polling
Shared Database
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
服務導向架構
Service-Oriented Architecture (SOA)
跨服務溝通
Cross-Service Communications
挑選跨服務溝通的實作架構
訊息佇列
Message Queue
Thanks!
DDD LightningTalks
By guansunyata
DDD LightningTalks
- 185