Skip to content
BENIBIX Learn

MVC vs MVVM

People think MVVM is just MVC with a new name, since both split screen code into three parts. In MVC, a controller takes the user's input and picks what the view shows. In MVVM, a view model holds the screen's state, and the view binds to it. Changes then flow both ways by themselves. The view model never touches the view, so it is easy to test.

Development🏗️ Architecture

Model-View-Controller (MVC)

Splits an app in three: data, screens and the code that links them.

Model-View-Controller, or MVC, splits an app into three parts. The model holds the data and the rules. The view shows the data to the user. The controller takes what the user does, updates the model and picks a view. The idea dates from the late 1970s and is still used by many web frameworks today.

Example
On Emma's blog, clicking a post goes to a controller. It asks the post model for the text and hands it to the post view, which draws the page.
Why it matters
It is the shape of many popular web frameworks. Knowing it tells you where to find each part of the code.
Full entry
Development🏗️ Architecture

Model-View-ViewModel (MVVM)

A way to split screen code into three parts. Data, the view, and a view model.

MVVM is a way to split an app's screen code into three parts. The model holds the data and the rules. The view is what the user sees, and it holds no logic. The view model sits between them and holds the screen's state and actions. The view is tied to the view model by data binding, so a change in one shows up in the other by itself. It is common in .NET apps.

Example
Emma's login screen binds its button to a SignIn command on the view model. She tests that command with no screen at all.
Why it matters
The view model can be tested without a screen. Designers can change the look without touching the logic.
Full entry

In one line

Model-View-Controller (MVC)
Splits an app in three: data, screens and the code that links them.
Model-View-ViewModel (MVVM)
A way to split screen code into three parts. Data, the view, and a view model.