Back to all terms
S1S2
State & Archbasic

MVC Pattern

An architectural pattern that separates an application into three interconnected components: Model (data), View (UI), and Controller (logic).

Also known as: Model-View-Controller, MVC Architecture

Description

The Model-View-Controller pattern is one of the oldest and most widely recognized architectural patterns in software engineering. It divides application concerns into three distinct layers: the Model, which manages data, business logic, and rules; the View, which renders the UI and presents data to the user; and the Controller, which accepts user input, manipulates the Model, and selects the appropriate View. This separation enables independent development, testing, and maintenance of each layer.

MVC originated in Smalltalk-80 and has since been adopted across virtually every platform and language. Web frameworks like Ruby on Rails, ASP.NET MVC, and Spring MVC implement server-side MVC where the controller handles HTTP requests and selects views for rendering. On the frontend, early frameworks like Backbone.js followed MVC loosely, though modern frontend frameworks have largely moved toward component-based or MVVM patterns instead.

The key benefit of MVC is enforced separation of concerns: designers can work on views without touching business logic, and backend engineers can modify models without breaking the UI. However, in large applications, controllers can become bloated (the "fat controller" anti-pattern), and the bidirectional data flow between layers can introduce complexity. Understanding MVC remains essential because it is the foundation upon which most other UI architectural patterns—MVVM, MVP, Flux—were built.

Prompt Snippet

Structure the application using a strict MVC separation where models encapsulate all domain logic and validation via class methods, controllers remain thin and delegate to service objects for orchestration, and views are pure rendering functions that receive serialized DTOs rather than raw model instances. Use Rails-style resourceful routing conventions to map HTTP verbs to controller actions, and enforce the no-logic-in-views rule through linter rules or a template engine that disallows arbitrary code execution.

Tags

architecturedesign-patternsseparation-of-concernsmvc