MVC, MVP, MVVM – Comparison of GUI Architecture Patterns
This article is a glossary entry on MVC, MVP, and MVVM – including exam questions, core elements, and tags.
In a Nutshell
MVC, MVP, and MVVM separate the user interface, logic, and data model to make GUI applications more maintainable and testable.
Compact Technical Description
- MVC: Controller mediates between View and Model.
- MVP: Presenter actively coordinates View and Model; View is as “dumb” as possible.
- MVVM: View binds to ViewModel (Data Binding); UI updates are more declarative.
Exam-Relevant Key Points
- MVC: View sends input to Controller, Controller changes Model
- MVP: Presenter knows View and Model, View is “dumb”
- MVVM: Data binding between View ↔ ViewModel
- Usage depends on framework (e.g., MVVM in WPF, MVC in Spring)
- Practice: Structuring, testability
- Security: Validation in Controller/Presenter/ViewModel
- Cost-effectiveness: Maintainability
- Documentation: Diagrams useful in GUI projects
Core Components
- Model
- View
- Controller (MVC)
- Presenter (MVP)
- ViewModel (MVVM)
- Data Binding
- Events/Callbacks
- Testability (Mocking)
- Validation
- Decoupling via Interfaces
Practical Example (Login)
MVC: View → Controller → Model → View
MVP: View → Presenter → Model → View
MVVM: View binds fields to ViewModel, Button triggers Command
Advantages and Disadvantages
Advantages
- Clear separation of concerns
- Higher testability
- Better maintainability
- Parallel development possible
Disadvantages
- Overhead in small projects
- Data binding can complicate debugging (MVVM)
Typical Exam Questions (with Brief Answers)
- Goal of MVC/MVP/MVVM? Separation of View/Model/Control.
- Main differences? Controller vs Presenter vs ViewModel + Binding.
- Where is MVVM typical? WPF/.NET, frameworks with binding.
- Advantage of MVP over MVC? Better testability through Presenter + Interface.
Glossary
| Term | Definition |
|---|---|
| MVC | Model-View-Controller |
| MVP | Model-View-Presenter |
| MVVM | Model-View-ViewModel |
Free Response
In IHK projects with GUI, you should choose one of these patterns and document it cleanly (e.g., diagram of data flows). In CLI tools, the overhead is usually unnecessary.
Learning Strategy
- Create a table (MVC/MVP/MVVM).
- Implement a mini-app in at least one pattern.
- Practice differences in bullet points.
- Don’t put business logic in UI components.
Topic Analysis
- Core: UI structuring
- Challenges: Binding/structural conflicts
- Security: Validation
- Documentation: Interaction diagrams
- Cost-effectiveness: Maintainability
Further Information
- https://learn.microsoft.com/en-us/dotnet/architecture/mvvm/
- https://spring.io/guides/gs/serving-web-content/