Model-View-Controller (MVC)
An architectural pattern that separates data model, presentation and control to improve maintainability and testability of UI-oriented systems.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeArchitectural
- Organizational maturityIntermediate
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Unclear boundaries lead to mixed logic
- Controllers becoming a dumping ground for business logic
- Lack of discipline in layer design increases maintenance costs
- Keep controllers thin; business logic in the model
- Define explicit contracts for view data
- Use automated tests to secure the separation
I/O & resources
- Domain model and business rules
- UI designs or templates
- Event and routing specifications
- Separated layers (model/view/controller)
- Improved test coverage and modularized components
- Documented interfaces and contracts
Description
MVC separates applications into Model, View and Controller to decouple data, presentation and user input. It improves maintainability, testability and parallel development in web and desktop applications through clear responsibilities. At the same time MVC increases architectural complexity, requires discipline and can lead to controller bloat.
✔Benefits
- Improved maintainability through clearly defined layers
- Better testability of business logic separate from the UI
- Facilitates parallel development of UI and backend
✖Limitations
- Increased architectural and coordination effort
- Not optimal for highly dynamic component-based UIs
- Can lead to oversized controllers (controller bloat)
Trade-offs
Metrics
- Proportion of unit-tested business logic
Measures percentage of domain logic covered by unit tests.
- Average controller size
Metric to detect controller bloat by LOC or number of methods.
- Time-to-change for UI adjustments
Time from change request to production delivery of a UI change.
Examples & implementations
Ruby on Rails
Rails implements MVC as a central architecture principle with clear conventions for models, views and controllers.
ASP.NET MVC
Microsoft's framework provides a structured MVC implementation for web applications with routing and controller lifecycle.
Desktop applications (e.g., Java Swing variants)
MVC concepts appear in many desktop UI frameworks to separate presentation and logic.
Implementation steps
Analyze existing code paths and identify responsibilities
Extract the domain model from UI logic
Implement views separate from controller logic
Add tests for model and controller layers
⚠️ Technical debt & bottlenecks
Technical debt
- Historically grown controllers with mixed logic
- Untested model functions in the codebase
- Missing interface definitions between views and controllers
Known bottlenecks
Misuse examples
- Moving complex validations into controllers instead of the model
- Using MVC as boilerplate without real layer separation
- Excessive use of global state between layers
Typical traps
- Insufficient tests for controller interactions
- Missing documentation of contracts between layers
- Inconsistent naming and responsibility assignment
Required skills
Architectural drivers
Constraints
- • Requires clear interface definitions
- • Not ideal for purely component-based frameworks without central controllers
- • Onboarding time for developers to apply correct layer separation