Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Using ArchUnit to test your architecture Matt Ho
Slide 2
Slide 2 text
About me - Hi, I'm Matt 👋 - 松凌科技 Architect / R&D - JCConf Speaker -
[email protected]
- https://github.com/shihyuho
Slide 3
Slide 3 text
放⼼, 這不是在講架構
Slide 4
Slide 4 text
本節在分享 架構已經在那了 && 該如何確保在持續開發/維運的過程中, 應⽤程式仍 然遵循著架構走
Slide 5
Slide 5 text
https://www.archunit.org/
Slide 6
Slide 6 text
ArchUnit Overview - 是⼀個測試套件, 整合了 JUnit 4, JUnit 5 等 - 良好的 Fluent API - 容易延伸擴充 - Apache-2.0 license
Slide 7
Slide 7 text
運作過程
Slide 8
Slide 8 text
起⼿式 決定從哪邊開始匯入 bytecodes
Slide 9
Slide 9 text
起⼿式 定義 Rules
Slide 10
Slide 10 text
起⼿式 ArchUnit 執⾏得到結果
Slide 11
Slide 11 text
起⼿式 - Rule Pattern ArchRuleDefinition.GIVEN_OBJECTS .that(). PREDICATE .should(). CONDITION
Slide 12
Slide 12 text
Controller 命名必須以 ‘Controller’ 結尾 Class Naming
Slide 13
Slide 13 text
Controller 命名必須以 ‘Controller’ 結尾 Class Naming
Slide 14
Slide 14 text
Class Naming Controller 命名必須以 ‘Controller’ 結尾
Slide 15
Slide 15 text
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Slide 16
Slide 16 text
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Slide 17
Slide 17 text
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Slide 18
Slide 18 text
Layered
Slide 19
Slide 19 text
Layered
Slide 20
Slide 20 text
Layered
Slide 21
Slide 21 text
Layered
Slide 22
Slide 22 text
Layered Architectures.layeredArchitecture() .layer(). PREDICATE .whereLayer(). CONDITION
Slide 23
Slide 23 text
Layered 定義 3 層 layer 定義依賴關係
Slide 24
Slide 24 text
General
Slide 25
Slide 25 text
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-(
Slide 26
Slide 26 text
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-( - 好吧, 那就現在開始的程式才檢查 :-)
Slide 27
Slide 27 text
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-( - 好吧, 那就現在開始的程式才檢查 :-) FreezingArchRule.freeze( ArchRuleDefinition.GIVEN_OBJECTS .that(). PREDICATE .should(). CONDITION )
Slide 28
Slide 28 text
Freeze
Slide 29
Slide 29 text
Code Smells
Slide 30
Slide 30 text
Long Parameter List https://refactoring.guru/smells/long-parameter-list
Slide 31
Slide 31 text
Large Class https://refactoring.guru/smells/large-class
Slide 32
Slide 32 text
Long Method https://refactoring.guru/smells/long-method
Slide 33
Slide 33 text
Recap - 起⼿式 - Naming Rules - Layers Rules - General Rules - Freezing Rules - Custom Rules - Code Smells
Slide 34
Slide 34 text
Thank you 🙌