Protocol Oriented Programming is a modified programming paradigm of object oriented programming introduced by Apple in 2015. Protocol Oriented Programming is similar to the interface in object oriented programming, where the protocols acts as a contract that defines methods, properties and other requirements needed to perform particular tasks. Protocol act as a contract because any type that adapts protocol promises to implement all requirements defined in the protocol. Protocol allow developers to write flexible and extensible code in Swift without having compromise with the language syntax or expression.

The idea behind implementing protocol oriented into MVVM (Model-View-ViewModel) is avoid the bad implementation and the code smells of MVC or MVVM model.

As shown in the picture 1.1, the implementation of Protocol Oriented in MVVM, greatly reduces number of duplicated functionality in the View-Model since each protocol has their own body or logic to be implemented by the needed View Controller such as ViewController11 and ViewController22, where both of the controllers need to implement the same function with the same logic.

 

References 

http://iosbrain.com/blog/2018/03/28/protocol-oriented-programming-in-swift-is-it-better-than-object-oriented-programming/

https://www.toptal.com/swift/introduction-protocol-oriented-programming-swift

https://docs.swift.org/swift-book/LanguageGuide/Protocols.html

Author : William 1901493415
Supervisor : Hanry Ham