Software Architectural Patterns: MVVM

Model

Similar to MVC, the Model is responsible for handling the business logic of the program. It models the data that is pulled in from the data source, and it can also encompass things such as networking code, persistence code, parsing, extensions, and more.

View

The View in MVVM is completely decoupled from the Model. The View’s sole purpose is to handle the user interface elements. This is one aspect of MVVM that allows teams to rapidly build when following the design pattern. UI/UX engineers can focus on the client-facing aspect of the program, while the back-end engineers can focus on the data modeling and business logic. Views are updated by the ViewModel.

ViewModel

The ViewModel is the object that transforms the Model’s data into information that can be displayed on a View. An example of such a transformation would be taking a `Date` type, and transforming it into a formatted string which would then be displayed on the View.

MVVM Architectural Pattern
MVVM Architectural Pattern Used in the iOS Ecosystem

When to Use MVVM

MVVM offers conciseness, especially when compared to MVC. Classes are more concise, the controller is more concise, and the views are more concise.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Lundy

Andrew Lundy

I write about programming and careers in tech.