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
220
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
220
Other Decks in Programming
See All in Programming
What is Parser
yui_knk
9
4.1k
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.5k
Some more adventure of Happy Eyeballs
coe401_
2
180
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
810
Desafios e Lições Aprendidas na Migração de Monólitos para Microsserviços em Java
jessilyneh
2
150
rails_girls_is_my_gate_to_join_the_ruby_commuinty
maimux2x
0
200
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
120
Jakarta EE meets AI
ivargrimstad
1
480
Swiftコードバトル必勝法
toshi0383
0
150
[DroidKaigi 2024] Android ViewからJetpack Composeへ 〜Jetpack Compose移行のすゝめ〜 / From Android View to Jetpack Compose: A Guide to Migration
syarihu
1
560
実践 Advanced CallKit 〜快適な通話の実現に向けて〜
mot_techtalk
3
140
watsonx.ai Dojo #2 生成AIを使ったアプリ開発入門編
oniak3ibm
PRO
0
110
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
5
480
Faster Mobile Websites
deanohume
304
30k
Debugging Ruby Performance
tmm1
72
12k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
123
18k
The Mythical Team-Month
searls
218
43k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
130k
Teambox: Starting and Learning
jrom
131
8.7k
Writing Fast Ruby
sferik
623
60k
Design by the Numbers
sachag
277
19k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
BBQ
matthewcrist
83
9.2k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
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