Intermediate Topic 27 of 50 Software Engineering
MVC Architecture
Separating model, view and controller responsibilities.
How it works
Model-View-Controller separates an application into three parts: the model holds data and business rules, the view presents data to the user and the controller handles input and coordinates between them. This separation lets each be developed, tested and changed independently, and several views can show the same model. Variants such as MVP, MVVM and component-based architectures adapt the idea to different frameworks.
Step-by-step walkthrough
- The user acts on the interface.
- The controller interprets the input.
- It updates the model, which holds data and rules.
- The view reads the model and renders it.
- The user sees the new state, and each part can change independently.
Where it is used
Web frameworks such as Rails, Django, Spring MVC and ASP.NET MVC, desktop applications and mobile apps use MVC or its variants to structure code.
Common pitfall
Fat controllers that hold business logic, or models that depend on views, defeat the purpose. Terminology differs between frameworks, so the roles are interpreted differently. Strictly separating can create boilerplate in small applications. Keep logic in the model or services, keep views simple and make controllers thin coordinators.
Where it fits in the course
MVC Architecture is topic 27 of 50 in Software Engineering, rated Intermediate. It follows Dependency Injection. The next topic is Refactoring.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Software Engineering quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Software Engineering quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is MVC Architecture?
Where do people use MVC Architecture?
What is the most common mistake with MVC Architecture?
What should I learn before this topic?
How can I practice it?
Is MVC Architecture hard to learn?
How long does it take to learn MVC Architecture?
Which topics are related to MVC Architecture?
What should I study after MVC Architecture?
Related topics
- Dependency Injection (Software Engineering)
- Refactoring (Software Engineering)
- Decorator Pattern (Software Engineering)
- Technical Debt (Software Engineering)
- Von Neumann Architecture (Computer Architecture & Logic)
- Instruction Set Architecture (Computer Architecture & Logic)
- IoT Architecture (Mobile, Embedded & IoT)