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
380
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
270
Other Decks in Programming
See All in Programming
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
300
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
1
860
エンジニア向け採用ピッチ資料
inusan
0
150
設計やレビューに悩んでいるPHPerに贈る、クリーンなオブジェクト設計の指針たち
panda_program
3
450
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
220
関数型まつり2025登壇資料「関数プログラミングと再帰」
taisontsukada
2
840
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
250
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
480
Is Xcode slowly dying out in 2025?
uetyo
1
180
社内での開発コミュニティ活動とモジュラーモノリス標準化事例のご紹介/xPalette and Introduction of Modular monolith standardization
m4maruyama
1
130
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
230
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
270
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
4
200
Embracing the Ebb and Flow
colly
86
4.7k
RailsConf 2023
tenderlove
30
1.1k
The Language of Interfaces
destraynor
158
25k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
490
Into the Great Unknown - MozCon
thekraken
39
1.9k
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