Slide 1

Slide 1 text

James Wang 2020 / 6 / 14 Agile Hsinchu 淺談 Domain Driven Design

Slide 2

Slide 2 text

I’m James • 公司內擔任 Programmer。 • 於 AgileCommunity.tw 與 Domain Driven Design Taiwan 擔任社群志工。 • 偶爾出沒感興趣主題的社群。 • 曾於 Agile Tour Taipei 和 Agile 新竹/高雄社群分享。 DDD Taiwan (FB) AgileCommunity.tw (FB)

Slide 3

Slide 3 text

大家聽過 Domain Driven Design 嗎?

Slide 4

Slide 4 text

可能是從微服務相關書籍看到 DDD。 或者學習系統架構時認識 DDD。 又或者系統開發中有加入 Domain 相關設計。

Slide 5

Slide 5 text

以上是 DDD,但不是完整的 DDD。

Slide 6

Slide 6 text

我們先來看見 DDD 的全貌

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

DDD 戰略

Slide 9

Slide 9 text

DDD 戰術

Slide 10

Slide 10 text

進入 DDD 要學的項目滿多的

Slide 11

Slide 11 text

還要把學會項目串接起來!

Slide 12

Slide 12 text

希望能用今天短短時間讓大家看到 DDD 入門的門。

Slide 13

Slide 13 text

What’s Domain Driven Design?

Slide 14

Slide 14 text

What's Domain Driven Design 簡介 我們看看提出 DDD 概念的 Eric Evans 的解釋: Tackling Complexity in the Heart of Software. 【軟體核心複雜度的解決方案】

Slide 15

Slide 15 text

Domain Driven Design 價值 DDD 其重要價值就是有系統地解構複雜的問題: The critical complexity of many software projects is in understanding the domain itself. 【軟體開發過程,最為關鍵複雜根本的原因是目標領域本身就錯綜複 雜】

Slide 16

Slide 16 text

Domain Driven Design 解決領域複雜的作法 我們該如何面對複雜的領域?如何控制複雜呢? Creative collaboration of software experts and domain experts. 【讓系統開發專家與領域專家協同合作】

Slide 17

Slide 17 text

Domain Driven Design 如何與領域專家協作 團隊 / 利害關係人透過工作坊形式與領域專家訪談: 1. EventStorming(事件風暴) 2. Domain Storytelling(領域敘事) 我知道的 他知道的 他知道的 他知道的 透過工作坊,認識領域知識。

Slide 18

Slide 18 text

ENTER EVENTSTORMING

Slide 19

Slide 19 text

先看看 EVENTSTORMING 樣貌 商業流程視覺化,找出核心價值、風險與機會。

Slide 20

Slide 20 text

EVENTSTORMING 環境準備

Slide 21

Slide 21 text

EVENT STORMING 參與人員 引導師 FACILITATOR 領域專家(們) DOMAIN EXPERT(S) 利害關係人 STAKEHOLDERS

Slide 22

Slide 22 text

EVENTSTORMING 三階段

Slide 23

Slide 23 text

PIG PICTURE EVENTSTORMING 目的 a large scale workshop where software and business practitioners are building together a behavioral model of a whole business line. 【聚集具有不同背景關係人(Business and technical stakeholders),並且每個人提供瞭解的部分領域知識,共同 建構整個業務架構。】

Slide 24

Slide 24 text

Start PIG PICTURE EVENTSTORMING have them model the entire business flow with Domain Events on a timeline.

Slide 25

Slide 25 text

PIG PICTURE – Step 1 Chaotic Exploration(混沌探索)

Slide 26

Slide 26 text

PIG PICTURE – Step 1 Chaotic Exploration(混沌探索)

Slide 27

Slide 27 text

PIG PICTURE – Step 2 Enforce the Timeline(執行時間) Pivotal Event:關鍵事件,代表不同業務場景階段之間的轉換

Slide 28

Slide 28 text

PIG PICTURE – Step 2 Enforce the Timeline(執行時間) Swimlanes:平行的業務流程

Slide 29

Slide 29 text

PIG PICTURE – Step 2 Enforce the Timeline(執行時間)

Slide 30

Slide 30 text

衝突 在討論過程中,若有衝突發生且無法解決,建議使用紅色便 利貼視覺化衝突內容。包括不清楚、不確定、有爭議的事物。

Slide 31

Slide 31 text

PIG PICTURE – Step 3 People & Systems

Slide 32

Slide 32 text

PIG PICTURE – Step 4 Explicit Walkthrough(明確演練)

Slide 33

Slide 33 text

以上步驟完成 BIG PICTURE 看見業 務流程全貌。

Slide 34

Slide 34 text

我們知道業務流程中會發生什麼事 件,但還是不夠。

Slide 35

Slide 35 text

我們應該要再思考我們能提供怎麼 差異化的價值來滿足顧客。

Slide 36

Slide 36 text

我們應該針對現有業務問題設計解 決方案。

Slide 37

Slide 37 text

接下來進入 Process Modeling 階段

Slide 38

Slide 38 text

PROCESS MODELING EVENTSTORMING 情境思考 小明於電商平台選了幾本書準備下單(總計金額 789 元)時, 發現限時特惠,買書滿 1000 元回饋 200 元禮券,每組帳號回 饋上限 400 元。 結果最後又加了幾本書,最後下單總金額 2012 元整,得到 了兩張 200 元的折扣券。

Slide 39

Slide 39 text

小明選好商品並已完成下單作業 小明 將選擇商品結帳 已結帳 為事件加上使用者(User / Actor)與完成事件所需行為(Command)

Slide 40

Slide 40 text

觸發小明買更多更多的商品 使用者(USER / ACTOR)看到(READ MODEL)什麼觸發更多事件 小明 將選擇 商品結帳 已結帳 滿千送 200 折扣抵用券

Slide 41

Slide 41 text

觸發小明買更多更多的商品 針對 READ MODEL,請 UI 和 UX 人員設計,產出 Prototype(UI) 小明 將選擇 商品結帳 已結帳 滿千送 200 折扣抵用券

Slide 42

Slide 42 text

觸發小明買更多更多的商品 小明 將選擇 商品結帳 已結帳 滿千送 200 折扣抵用券 每組帳號 最多兩張

Slide 43

Slide 43 text

PROCESS MODELING EVENTSTORMING

Slide 44

Slide 44 text

EVENTSTORMING 書中 Pizza 範例

Slide 45

Slide 45 text

PROCESS MODELING EVENTSTORMING 重點 • 瞭解公司戰略目標(Goals)與限制 • 依據目標設計商業流程策略 • 過程中可使用 User Story 和實際案例(Examples)討論

Slide 46

Slide 46 text

PROCESS MODELING EVENTSTORMING 重點 • 這過程沒有想像中簡單

Slide 47

Slide 47 text

PROCESS MODELING EVENTSTORMING 重點 • 這過程沒有想像中簡單

Slide 48

Slide 48 text

PROCESS MODELING EVENTSTORMING 重點 • 這過程沒有想像中簡單

Slide 49

Slide 49 text

PROCESS MODELING EVENTSTORMING 成品展示

Slide 50

Slide 50 text

進入 Software Design 階段

Slide 51

Slide 51 text

Aggregate 將概念相近的地方收攏放在一起

Slide 52

Slide 52 text

Bounded Context 再次將概念收攏,找出軟體的邊界。

Slide 53

Slide 53 text

Context Map Bounded Context 間的關聯性。

Slide 54

Slide 54 text

到此,使用 EVENTSTORMING 完成 DDD 戰略部分

Slide 55

Slide 55 text

EVENTSTORMING 可以和大家常聽到 的 Impact Mapping 或 User Story Mapping 結合使用。

Slide 56

Slide 56 text

EVENTSTORMING 也可以和 UX 常用 手法結合,譬如 Persona 或 Service Blueprinting 或 User Journey Mapping。

Slide 57

Slide 57 text

DDD 戰略

Slide 58

Slide 58 text

再深入解釋 DDD 重要的兩個概念

Slide 59

Slide 59 text

Bounded Context(BC) DDD 核心最重要概念之一。 DDD deals with large models by dividing them into different Bounded Contexts and being explicit about their interrelationships.

Slide 60

Slide 60 text

透過 Bounded Context Canvas 切分 Bounded Context

Slide 61

Slide 61 text

團隊與領域專家合作優點 • 一同瞭解複雜的領域全貌。 • 將複雜領域拆分成較小且易於解決的 Bounded Context。 • 建立團隊 Ubiquitous Language。 A language structured around the domain model and used by all team members to connect all the activities of the team with the software. 【一種圍繞領域模型構造的語言,所有團隊成員都使用該語言, 將團隊所有活動與系統聯繫起來。】 ... within a bounded context. 【...在限界上下文的範圍內。 】

Slide 62

Slide 62 text

Ubiquitous Language(UL) DDD 核心最重要概念之一。 在臺灣,代表 OK 沒有問題的意思。 在巴西,這是很粗魯的手勢。 Bounded Context Ubiquitous Language

Slide 63

Slide 63 text

Ubiquitous Language(UL) DDD 核心最重要概念之一。

Slide 64

Slide 64 text

DDD 戰略流程 Complexity Domain UL Bounded Context UL Bounded Context UL Bounded Context U U D D Stakeholders Domain Experts Event Storming Domain Storytelling

Slide 65

Slide 65 text

戰略到一段落。接下來,進入建模與 開發階段。

Slide 66

Slide 66 text

How to map it in code?

Slide 67

Slide 67 text

建模

Slide 68

Slide 68 text

© 2020, Domain Driven Design Taiwan Community Aggregate Canvas Overview Concern TODO Concern Scenario Name • Item1 • Item2 • Item3 Domain Service Command Command Command Command Domain Service Application Service Application Service Use Case Use Case Use Case Use Case Use Case Use Case Scenario Scenario Scenario DDDDD: Aggregate Canvas: A fluent way to walk through Strategical modeling to tactical design

Slide 69

Slide 69 text

接下來進入開發階段,建議採用 BDD 與 TDD(尤其是重要的 Domain Model)。

Slide 70

Slide 70 text

今天簡單說了 Domain Driven Design 戰略部分 戰略 Strategic 戰術 Tactical • Bounded Context • Context Map • 系統開發相關 備註:戰略到戰術是持續迭代持續改進的流程。 建模 (聚合畫布)

Slide 71

Slide 71 text

總結 DDD 是軟體核心複雜度的解決方案。當你面對複雜的領域時, 可以使用 DDD 建置乾淨又貼合業務領域的系統。 當你使用 DDD 後,會發現寫出來的系統自然以領域知識劃分, 寫出接近於微服務架構系統。 DDD 可以融合 UX / Agile / DevOps / XP …… 等概念,也能與 User Story Mapping …… 等方法結合。

Slide 72

Slide 72 text

Understand Client Needs Build Software Write Code Solve Problems

Slide 73

Slide 73 text

Ubiquitous Language UL UL UL U D D Bounded Context Bounded Context Bounded Context Stackholders Domain Experts Feedback Refactoring Coding Red Green Refactoring Modeling U Potentially Shippable Product Increment Merge the people, split the software.

Slide 74

Slide 74 text

更多學習資源 歡迎加入 Domain Driven Design Taiwan 社群。 連結:https://tinyurl.com/ychs4x3w

Slide 75

Slide 75 text

更多學習資源 領域驅動設計 領域驅動設計精粹 實現領域驅動設計 EVENTSTORMING 社群高手整理的 DDD 學習路徑與資源分享 DDD 書籍推薦 這份鐵人賽 30 天文章 非常推薦新手入門學習。

Slide 76

Slide 76 text

DDD 社群近期活動 • 如果想要深入瞭解 DDD 在小型 專案或導入相關議題嗎? • 如果想要知道 DDD 與微服務之 間的關連嗎? • 如果想要探索 DDD 戰術開發常 被人遺忘卻很有用的技巧嗎? DDD TW 於 6/27(六) 下午線上三場 講座,一次滿足大家三個願望。 https://tinyurl.com/y7cj725c