Swift MVVM design pattern

Tuesday, 28 August 2018

Swift MVVM design pattern


Design pattern is an important part for code reusability.

History
Since the beginning of it's development, iOS has used MVC (Model View Controller) design pattern, which helps the developers to reuse code. It also helps to keep UI and business logic separately.

Why MVVM ?
In MVC, As the View and Controller is combined in the ViewController, the controller overloaded. So in order to reduce the code size in controller, MVVM pattern has been introduced.

In MVVM pattern, ViewController does not interact directly with the Model unlike in MVC. Here, ViewController interacts with ViewModel, and ViewModel interact with the Model.

Model(Database) <-->ViewModel (Business Logic) <--> ViewController (UI/View related code)

There are some other architecture design pattern also there like MVC, MVP, MVVM, Viper etc.

Check out below link for MVVM architecture pattern example in Swift.

https://youtu.be/FBJzPppZLsg





0 Comment on "Swift MVVM design pattern"

Post a Comment

MVVM

Swift MVVM design pattern

Design pattern is an important part for code reusability. History Since the beginning of it's development, iOS has used MVC (Mo...