Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JCConf 2022 - Using ArchUnit to test your archi...
Search
Shihyu Ho
October 15, 2022
Technology
0
130
JCConf 2022 - Using ArchUnit to test your architecture
Using ArchUnit to test your architecture
Shihyu Ho
October 15, 2022
Tweet
Share
More Decks by Shihyu Ho
See All by Shihyu Ho
JCConf 2024 Jib
shihyuho
0
27
hybrid-cloud-seminar.pdf
shihyuho
0
86
JCConf 2021 Access Kubernetes API in Java
shihyuho
0
110
JCConf 2020 Observing in Microservices
shihyuho
0
690
iThome Kubernetes Summit 2018
shihyuho
0
55
JCConf 2016 zookeeper
shihyuho
0
53
Other Decks in Technology
See All in Technology
RubyでKubernetesプログラミング
sat
PRO
4
160
今年一年で頑張ること / What I will do my best this year
pauli
1
220
2025年のARグラスの潮流
kotauchisunsun
0
790
AWSの生成AIサービス Amazon Bedrock入門!(2025年1月版)
minorun365
PRO
7
470
自社 200 記事を元に整理した読みやすいテックブログを書くための Tips 集
masakihirose
2
330
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!事例のご紹介+座学②
siyuanzh09
0
110
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
220
ABWGのRe:Cap!
hm5ug
1
120
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
2.4k
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!座学①
siyuanzh09
0
110
I could be Wrong!! - Learning from Agile Experts
kawaguti
PRO
8
3.4k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Navigating Team Friction
lara
183
15k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Six Lessons from altMBA
skipperchong
27
3.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Designing Experiences People Love
moore
139
23k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
A Tale of Four Properties
chriscoyier
157
23k
Building Your Own Lightsaber
phodgson
104
6.2k
Transcript
Using ArchUnit to test your architecture Matt Ho
About me - Hi, I'm Matt 👋 - 松凌科技 Architect
/ R&D - JCConf Speaker -
[email protected]
- https://github.com/shihyuho
放⼼, 這不是在講架構
本節在分享 架構已經在那了 && 該如何確保在持續開發/維運的過程中, 應⽤程式仍 然遵循著架構走
https://www.archunit.org/
ArchUnit Overview - 是⼀個測試套件, 整合了 JUnit 4, JUnit 5 等
- 良好的 Fluent API - 容易延伸擴充 - Apache-2.0 license
運作過程
起⼿式 決定從哪邊開始匯入 bytecodes
起⼿式 定義 Rules
起⼿式 ArchUnit 執⾏得到結果
起⼿式 - Rule Pattern ArchRuleDefinition.GIVEN_OBJECTS .that(). PREDICATE .should(). CONDITION
Controller 命名必須以 ‘Controller’ 結尾 Class Naming
Controller 命名必須以 ‘Controller’ 結尾 Class Naming
Class Naming Controller 命名必須以 ‘Controller’ 結尾
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Class Naming Data Access 命名必須以 ‘Dao’ 結尾
Layered
Layered
Layered
Layered
Layered Architectures.layeredArchitecture() .layer(). PREDICATE .whereLayer(). CONDITION
Layered 定義 3 層 layer 定義依賴關係
General
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-(
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-( - 好吧, 那就現在開始的程式才檢查 :-)
Freeze - 套⽤在舊的系統中, 超多條違規改不動 ;-( - 好吧, 那就現在開始的程式才檢查 :-) FreezingArchRule.freeze(
ArchRuleDefinition.GIVEN_OBJECTS .that(). PREDICATE .should(). CONDITION )
Freeze
Code Smells
Long Parameter List https://refactoring.guru/smells/long-parameter-list
Large Class https://refactoring.guru/smells/large-class
Long Method https://refactoring.guru/smells/long-method
Recap - 起⼿式 - Naming Rules - Layers Rules -
General Rules - Freezing Rules - Custom Rules - Code Smells
Thank you 🙌