MVVM and the Swift Type System

The series of video lectures given to Stanford University students in Spring of 2020 continues with a conceptual overview of the architectural paradigm underlying the development of applications for iOS: MVVM. In addition a key concept in the Swift Programming Language, its type system, is explained. The Memorize demonstration continues, incorporating MVVM.

It is impossible to develop applications for iOS using SwiftUI without using the MVVM architecture for organizing your code. This lecture explains what that is and then demonstrates how it works in our demonstration application. SwiftUI development happens entirely in the programming language Swift. Swift is unique in its support of most modern language features, including both object-oriented programming and functional programming. Since functional programming is new to most Stanford students, this lecture starts the process of explaining how it works by covering the basics of Swift’s type system, including structs and classes, generics and functions as types. The demonstration then moves to the next level using the MVVM architecture (including creating a Model, a ViewModel, expressing user’s intent from the View) and utilizing Swift features like generics and functions as types. After this lecture, students take over the development of Memorize for their first assignment.

Archived course materials (homework assignments and lecture slides) are available at https://cs193p.stanford.edu.


Leave a Comment

We don't require your email address, or your name, for anyone to leave a comment. If you do add an email address, you may be notified if there are replies to your comment - we won't use it for any other purpose. Please make respectful comments, which add value, and avoid personal attacks on others. Links are not allowed in comments - 99% of spam comments, attempt to post links. Please describe where people may find additional information - for example "visit the UN website" or "search Google for..." rather than posting a link. Comments failing to adhere to these guidelines will not be published.