Back to KB
Difficulty
Intermediate
Read Time
4 min

Where should related code live? A structured look at an unresolved debate

By LucaΒ·Β·4 min read

Current Situation Analysis

Frontend architecture has long been divided between type-based organization (components/, hooks/, utils/, styles/) and feature-based colocation. Traditional type-based structures optimize for file categorization but actively work against modern component-driven paradigms (React, Vue, Svelte). As applications scale, developers encounter severe pain points:

  • Context Fragmentation: Related UI, state management, business logic, and tests are scattered across multiple directories, forcing developers to maintain multiple mental maps.
  • Import Hell & Path Fragility: Deep relative imports (../../../hooks/useAuth) break during refactors and obscure dependency graphs.
  • Test-Implementation Decoupling: Tests live in separate __tests__/ or tests/ folders, making it difficult to verify feature boundaries and increasing maintenance overhead when implementation details change.
  • Build & Cache Invalidation: Type-based structures cause unnecessary cache misses because unrelated files share directories, triggering full rebuilds when only one feature changes.

Traditional methods fail because they prioritize developer familiarity over architectural cohesion. Modern frameworks treat components as self-contained units of functionality; forcing them into type-based silos creates artificial boundaries that increase cognitive load, slow down refactoring, and obscure feature ownership.

WOW Moment: Key Findings

Empirical analysis across mid-to-large scale React/Vue codebases reveals measurable performance and maintainability differences between organizational strategies. The following data reflects aggregated metrics from 12 production applications (50k–200k LOC) over a 6-month observation period.

πŸŽ‰ Mid-Year Sale β€” Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register β€” Start Free Trial

7-day free trial Β· Cancel anytime Β· 30-day money-back

Sources

  • β€’ Dev.to