Swift 5: Protocol-Oriented Programming
1h 59mAdvanced2020-01-15
Authors

Károly Nyisztor
Mobile Developer, Instructor
Course details
Take a closer look at protocol-oriented programming (POP), a new paradigm introduced by Apple. In this course, instructor Károly Nyisztor explains what POP is, how it differs from classical approaches, and how to work with it to efficiently develop apps with Swift. Learn about the pillars of POP: protocol extensions, protocol inheritance, and protocol composition. Protocol extensions let you define default behavior for conforming types without defining a base class. Protocol inheritance is a powerful feature that lets you create more granular designs. Swift does not allow multiple inheritance for classes—but with protocol composition, Swift types can adopt multiple protocols. Plus, explore generics, and see how to implement a fully functional app using a protocol-oriented approach.
Learning objectives
Comparing OOP with POP
Adopting a protocol
Working with generic types
Using generics with protocols
Implementing an app using POP
Integrating a fallback service
Learning objectives
Comparing OOP with POP
Adopting a protocol
Working with generic types
Using generics with protocols
Implementing an app using POP
Integrating a fallback service
Skills covered
SwiftiOSAppleProgramming LanguagesSoftware DevelopmentDeep Dive (X:Y)
Concepts
Introduction
- benefits- protocol-oriented programming
- what you should know
The Pillars of Protocol Orientation
- what is protocol-oriented programming-
- introducing the protocol
- adopting protocols
- conforming to protocols via extensions
- understanding polymorphism
- protocol inheritance
- adopting multiple protocols
- protocol extensions
- challenge- removing tight coupling
- solution- removing tight coupling
Protocol-Oriented Programming
- why protocols-
- from unstructured code to pop
- designing with classes- first try
- designing with classes- subclassing
- the benefits of thinking in protocols
- highlighting the differences
Generics
- the importance of generics
- defining generic functions and methods
- working with generic types
- placeholder types in protocols
- using generics with protocols
- challenge- implementing a generic stack
- solution- implementing a generic stack
Implement the Weather App Using POP
- weather app design
- defining the ui using swiftui
- the webservicecontroller protocol
- working with a third-party api
- implementing the openweathermap controller
- completing the openweathermap controller
- introducing the view model
- presenting weather data
- challenge- integrating a fallback service
- solution- integrating a fallback service
Conclusion
- next steps