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
160
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
61
hey-techcamp-2022
garebareda
2
80
Rustで作った自作コマンド群の話
garebareda
0
180
自作Git作った話
garebareda
3
840
Rustで自作言語のインタプリタ作って Webで動くようにした話
garebareda
0
880
Vtuberをやりたくなりました
garebareda
1
93
Other Decks in Programming
See All in Programming
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.7k
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
1
1.2k
App Intentsのビルドプロセスを支える技術
kntkymt
0
490
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
140
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
120
setup-vp GitLab対応の裏側
naokihaba
0
140
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.7k
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
AWSに止められる覚悟してますか?
morizo_1984
2
490
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Code Review Best Practice
trishagee
74
20k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Deep Space Network (abreviated)
tonyrice
0
350
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
4 Signs Your Business is Dying
shpigford
187
23k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
540
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
400
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
450
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代わりにして 解決!
ただ必要な関数が増えるたびに 引数も増えます