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
クリーンアーキテクチャ をGoでする場合に不要な Interfaceは消しやがれ
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
garebare
June 17, 2022
Programming
150
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
More Decks by garebare
See All by garebare
ペンギンをおすすめする
garebareda
0
58
hey-techcamp-2022
garebareda
2
80
Rustで作った自作コマンド群の話
garebareda
0
180
自作Git作った話
garebareda
3
800
Rustで自作言語のインタプリタ作って Webで動くようにした話
garebareda
0
870
Vtuberをやりたくなりました
garebareda
1
88
Other Decks in Programming
See All in Programming
Claude Team Plan導入・ガイド
tk3fftk
0
210
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
220
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
650
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
Performance Engineering for Everyone
elenatanasoiu
0
270
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
950
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
860
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
0
280
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
770
5分で問診!Composer セキュリティ健康診断
codmoninc
0
330
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
130
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
460
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
470
Mind Mapping
helmedeiros
PRO
1
280
Color Theory Basics | Prateek | Gurzu
gurzu
0
390
Ethics towards AI in product and experience design
skipperchong
2
330
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
320
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Building Adaptive Systems
keathley
44
3.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
340
[SF Ruby Conf 2025] Rails X
palkan
2
1.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Transcript
クリーンアーキテクチャを 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代わりにして 解決!
ただ必要な関数が増えるたびに 引数も増えます