Last week, I had an interesting conversation with a reader, let’s call him John, about the Model-View-ViewModel pattern. The questions John asked me show that developers new to MVVM often miss or overlook the more profound benefits the pattern brings to the table. In this post, I’d like to share with you the most important insights of our conversation.
The first programming language I picked up was PHP and, since it was my first experience programming, I immediately loved it. At that time, I had no idea what object-oriented programming was. The result was a lot of spaghetti code that did something.
Most Cocoa applications are powered by the Model-View-Controller pattern, MVC for short. MVC is easy to understand and has very little overhead. But those that have used the Model-View-Controller pattern for some time know that it isn’t perfect. Not even close. The Model-View-ViewModel pattern offers an interesting alternative.
Yesterday, you learned how to use view models in a view controller that isn’t driven by data. We refactored the settings view controller of Cloudy.
In Mastering Model-View-ViewModel With Swift 3, we explore how you can use the Model-View-ViewModel pattern to simplify table views. The example we use in the course is Cloudy, a weather application powered by the Dark Sky API. The settings view of the application contains a handful of settings.
If you are familiar with the Model-View-Controller pattern, then you know that it splits an application up into three components or layers: the view layer the model layer and the controller layer