๐ Colocation matters. Cognitive load matters. Boundaries matter. High cohesion matters. Yes, even in the age of AI (maybe even more so). Enter the vertical codebase:
11 reposts73 likes
๐ Colocation matters. Cognitive load matters. Boundaries matter. High cohesion matters. Yes, even in the age of AI (maybe even more so). Enter the vertical codebase:
11 reposts73 likes
The hardest part is definitely defining the right verticals for a piece of code, as you pointed out. Josh Comeau's piece on file structure does a good job explaining why people might default to horizontal structure. www.joshwcomeau.com/react/file-s...
Based on the above: src/ โโโ user/ โ โโโ queries.ts โ โโโ mutations.ts โ โโโ component1.tsx โ โโโ use-something.ts โ โโโ sub-domain/ โ โโโ queries.ts โโโ routes/ โโโ user <- imports from user vertical primarily + any others โโโ user.index.ts โโโ $userId.tsx
Excellent write-up! I'm currently in the proces of migrating from a shared folder + vertical route boundary to something similar because a route as a boundary is too limiting. I also like the approach of fsd.how. It goes beyond just a feature vertical and includes strict import rules + enforcement.
We talk about 'horizontal codebases' but an even nastier version imo would be the 'route tree codebases' for frontend apps: Everything is collocated with the routes, unless it isn't. Then we fallback to horizontal splitting. And then you gotta put in 10x the effort to migrate away from it and ๐ซจ ugh
Yeah I've been there. I'd rather have the route(s) defined within the domain package. I know @beaussan.io has some ideas for @tanstack.com router in this regard ๐