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
Feature driven folder structureは何を解決する?
Search
eraser5th
October 15, 2022
Programming
0
410
Feature driven folder structureは何を解決する?
eraser5th
October 15, 2022
Tweet
Share
More Decks by eraser5th
See All by eraser5th
Vanilla-extractで タイプセーフに始める Utility first CSS
eraser5th
0
280
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
320
AI時代のドメイン駆動設計-DDD実践におけるAI活用のあり方 / ddd-in-ai-era
minodriven
25
9.7k
AIエージェント開発、DevOps and LLMOps
ymd65536
1
380
AI時代のUIはどこへ行く?
yusukebe
12
7.4k
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1.4k
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
160
MCPで実現するAIエージェント駆動のNext.jsアプリデバッグ手法
nyatinte
7
1k
Go言語での実装を通して学ぶLLMファインチューニングの仕組み / fukuokago22-llm-peft
monochromegane
0
110
AIでLINEスタンプを作ってみた
eycjur
1
220
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
18
9.7k
AIレビュアーをスケールさせるには / Scaling AI Reviewers
technuma
2
240
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
460
Featured
See All Featured
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
Music & Morning Musume
bryan
46
6.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
11
1.1k
Writing Fast Ruby
sferik
628
62k
Faster Mobile Websites
deanohume
309
31k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
4 Signs Your Business is Dying
shpigford
184
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
Feature driven folder structure は何を解決する? 2023 春大LT 学部 3 年
ERASER (加藤 豪) Press Space for next page
ERASER 加藤 豪 会津大学 学部3年 Twitter, GitHub ポートフォリオ 技術 言語:JS
・TS 、CSS 、HTML 、Lua 、Rust( 簡単な競プロ) 、Haskell( 勉強中) Web フロント:React.js 、Next.js 、GraphQL(Apollo Client) 、CSS-in-JS バックエンド:Node.js 、Prisma(ORM) 、 ツール:Git ・GitHub 、Figma 好きなもの Neovim 、Wezterm 、綺麗なコードを考える Vtuber 、スプラ、EGOIST
前置き 今回のお話はマサカリの飛びやすい分野だと思います。 もし適当なことを言っていたりしたら、シメていただけると泣いて喜びます。
Feature driven folder structure ってなんぞ? 機能駆動のフォルダ構造です(翻訳しただけ)。 src/ └ features/ ├
login/ ├ use-login.ts ├ login-page.tsx └ login-form.tsx ├ ui/ ├ button.tsx ├ card.tsx └ ... └ ... ...
Feature driven folder structure は何を解決する? これが何を解決するのか? それについて考えていくのが今回のお話です。
こんなReact のコードベース、見たことない? よくある、かは知らないが、僕がこれまでよくやっていたReact のコードベース src/ ├ components/ ├ context/ ├
hooks/ ├ pages/ ├ lib/ └ App.ts
こんなReact のコードベース、見たことない? これはアンチパターン「技術駆動パッケージング」 の一例です src/ ├ components/ ├ context/ ├
hooks/ ├ pages/ ├ lib/ └ App.ts
技術駆動パッケージングというアンチパターン
技術駆動パッケージングというアンチパターン 技術駆動のどこが良くないのでしょうか? 先程のディレクトリ構成の内の一部を中身が見えるようにしてみましょう。 src/ ├ components/ ├ login-form.tsx └ ...
├ hooks/ ├ use-login.tsx └ ... └ pages/ ├ login-page.tsx └ ... ...
技術駆動パッケージングというアンチパターン 今度は全体ではなく components の中を見てみます。 今回は簡単と誇張のために components 内部は全てフラットであるものとしました。 ` ` src/
├ components/ ├ button.tsx ├ card.tsx ├ login-form.tsx ├ user-profile-card.tsx └ ... ... ` `
技術駆動パッケージングの問題点 まずはこちらから。 ログインのフックとコンポーネントとページがバラバラの場所にあり、把握がしずらい src/ ├ components/ ├ login-form.tsx └ ...
├ hooks/ ├ use-login.tsx └ ... └ pages/ ├ login-page.tsx └ ... ...
技術駆動パッケージングの問題点 そして次にこちら。 button と login-form が同じレイヤにいるなど、 components の抽象度がバラバラ 用途の全く違う login-form
と user-profile-card が同じパッケージ(ディレクトリ)にいる src/ ├ components/ ├ button.tsx ├ card.tsx ├ login-form.tsx ├ user-profile-card.tsx └ ... ... ` ` ` ` ` ` ` ` ` `
技術駆動パッケージングの問題点 これらの問題を生み出すものの名前なんというか、我々は知っています。 凝集度です。 となると components の凝集度はどれに当たるでしょう? おそらくは最低最悪の偶発的凝集です。 凝集度については説明は省きます(一人大LT になってしまう) `
`
技術駆動パッケージングの改善 技術駆動パッケージングの問題点が、 ある機能の低凝集と、それぞれのディレクトリ内部の偶発的凝集だと分かったので これらを機能的凝集へと改善しましょう
技術駆動パッケージングの改善 段階的にやるのは面倒なので結果をドン! src/ └ features/ ├ login/ ├ use-login.ts ├
login-page.tsx └ login-form.tsx ├ ui/ ├ button.tsx ├ card.tsx └ ... └ ... ...
技術駆動パッケージングの改善 やったことは二つ。 偶発的凝集を起こしていたパッケージ、components ・hooks ・pages を削除 その中身を機能ごとにパッケージング src/ └ features/
├ login/ ├ use-login.ts ├ login-page.tsx └ login-form.tsx ├ ui/ ├ button.tsx ├ card.tsx └ ... └ ... ...
Re: Feature driven folder structure は何を解決する?
最後に
「銀の弾などない」(戒め)
fin ご清聴ありがとうございました!
参考記事 Screaming Architecture - Evolution of a React folder structure
Screaming Architecture