AI summary by TwinMind
Separations of Concerns is a Lie
Theo - t3․gg
8m 50s
Introduction and Main Thesis
- Developer planning video for over a year on separation of concerns critique
- Main argument: separation of concerns as default creates poor developer experience
- References previous discussions on Tailwind and server components
Definition of Separation of Concerns and MVC
- Separation of concerns: breaking app into categories by function types
- MVC (Model View Controller) most common implementation
- Model: central component, dynamic data structure independent of UI
- View: displays what model determines to user
- Controller: accepts inputs, converts to commands for model/view
- Argues this separation is "entirely arbitrary and makes no sense in modern times"
Historical Context and Evolution
- Made sense when HTML was limited infrastructure piece
- Angular (especially AngularJS) built around MVC model
- React threw away MVC approach
- Allowed developers to define boundaries themselves
- Combined MVC parts, gave developers control over separation
Mark Dalgleish Tweet and ESLint Rule Example
- Mark Dalgleish (vanilla extract creator, CSS modules, remix) tweeted apology
- Referenced 8+ year old commit adding "no-setState" ESLint rule
- Rule prevented components from updating their own state
- Required external state updates through UI libraries
- Separated update layer from React view layer
- Result: exponentially increased complexity
- Finding files became massive challenge
- Updates risked breaking other components
- State could be "seven layers away" from current location
Colocation Benefits
- Closer code location = easier maintenance, understanding, review
- Never seen separation of concerns make real changes easier at any company scale
- Common problem: missing one of "15 places that need changing"
- Looks fine in code review
- Actually broken due to unseen impacts
- Code review issues when model logic separated from consumption points
Tailwind CSS Example
- People upset about "words in JSX/HTML"
- Collocating styles with rendering elements provides benefits:
- Easier to see what causes behavior
- Easier to make changes
- Easier code review
- Harder to accidentally leave old styles
- Separated CSS files create problems:
- Can't safely delete unused classes
- No relationship between CSS file and HTML rendering
- Estimates 25% of Twitch CSS currently unused but kept due to deletion fears
- Common issues: misspelled class names, duplicate CSS names
Server-Client Side Considerations
- Argues server could send appropriate HTML based on conditions
- Demonstrates with server components example:
const data = await getImagesForUser()(SQL call in function)- Returns
ImageGridReact component - Both defined in same file
- Benefits of colocation:
- Easier to see backend returns and UI effects
- Adding features (e.g., zero images handling) goes from "annoying to trivial"
- Backend devs can understand client impact
Version Management and GraphQL
- Separated backend/frontend creates version skew problems
- Difficult to understand change impacts across sides
- GraphQL invented to manage these separation difficulties
- Avoiding default separation allows developers to define boundaries where sensible
Complexity Arguments
- Separation of concerns sold as complexity reduction solution
- Reality: increases feature complexity since features touch all separated boxes
- Good if boxes match team structure, but most teams now built around features, not stack locations
- Example workflow problems:
- Frontend team needs backend changes
- Back-and-forth process for backwards compatibility
- API mismatches requiring additional changes
- Slower development, reduced confidence
Infrastructure Distance Impact
- Current: multiple teams, files, codebases, deployment infrastructure between UI and infrastructure
- Proposed: two lines of code distance
- Makes maintenance significantly easier
Scale and Experience Observations
- Worked at different scales, seen separation of concerns cause more problems than solutions
- Believes it shouldn't be default approach
- Current default: separated database, API with Express, SPA frontend, MVC separation on both ends
- "This died with rails, isn't how we should build anymore"
Conclusion and Call for Feedback
- Requests examples where separation of concerns benefits as default
- Advocates for defaulting to simplest approach
- Separate when problems arise, not preemptively
- References FSE stack as future of development
