Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
クリーンアーキテクチャ をGoでする場合に不要な Interfaceは消しやがれ
Search
garebare
June 17, 2022
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
クリーンアーキテクチャ をGoでする場合に不要な Interfaceは消しやがれ
6月17日に行われたNEWDEBUG!!!!で発表した史料です。
https://caspur.wintu.dev/front/lives/264
garebare
June 17, 2022
Transcript
28 slides
クリーンアーキテクチャを Goでする場合に不要な Interfaceは消しやがれ @garebare521
By たふみ神
ということで考えて行こうと思います
クリーンアーキテクチャとは
Entity UseCase Cotroller UI DB
なんかこういうやつ!
Interfaceで依存を逆転させてるらしい
実装例 type Hoge struct { … } type HogeUsecase struct
{ … } type HogeRepository struct { …. } type Hoge Controller struct { … }
実装例 hogeRepo:=NewHogeRepository() hogeUse :=NewHogeUsecase(hogeRepo) hogeCtrl := NewHogeCtroller(hogeUse)
実装例 hogeCtrl.Post () hogeUse.Post () HogeRepo.Insert()
Interfaceなしだと モックが作れないので テストし難い
Interface書くしかない
クリーンアーキテクチャを Goでする場合に不要な Interfaceは消しやがれ
じゃあどうするか
とりあえず実装量が少なそうな UseCase層を取り除く
Entity UseCase Cotroller UI DB
Entity Cotroller UI DB
単純にインターフェースを削除すると テストが破綻する
テストしやすい形にしたい
じゃあもう実態持たせる必要なくない?
Entity UI DB Controller
Entity UI DB Controller こうしたい
実態を持たせずに Interfaceと同じようなことをしたい
関数を引数に渡せばよくね????
関数を渡すようにするとテストも書きやすい
HogeController func (c *hogeCtrl) Post(c Context, insert func(hoge Hoge) (error))
{ insert() } hogeCtrl.Post(c, hogeRepo.insert)
関数の引数をInterface代わりにして 解決!
ただ必要な関数が増えるたびに 引数も増えます
More Decks by garebare
See All by garebare
ペンギンをおすすめする
garebareda
0
65
hey-techcamp-2022
garebareda
2
86
Rustで作った自作コマンド群の話
garebareda
0
190
自作Git作った話
garebareda
3
890
Rustで自作言語のインタプリタ作って Webで動くようにした話
garebareda
0
880
Vtuberをやりたくなりました
garebareda
1
98
Other Decks in Programming
See All in Programming
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
190
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
310
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
260
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
180
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
100
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
330
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
210
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
270
Seven New Principles of Software Engineering
yegor256
0
500
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
200
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.3k
sira's awesome portfolio website redesign presentation
elsirapls
0
510
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
The Limits of Empathy - UXLibs8
cassininazir
2
790
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
600
The SEO identity crisis: Don't let AI make you average
varn
0
630
The Invisible Side of Design
smashingmag
301
52k
How STYLIGHT went responsive
nonsquared
100
6.4k
Done Done
chrislema
187
17k
Skip the Path - Find Your Career Trail
mkilby
1
290
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
6
930