Advanced Swift: Protocol Oriented Programming
Swift protocol oriented programming gives you the power of object oriented programming with better composability and without the baggage of class inheritance. By Ray Fix.
Learning path
This is part of the Advanced Swift learning path. View path.
Who is this for?
This course is for developers interested in getting a deeper understanding of the Swift language. It expects you to be comfortable with the basic syntax of Swift and to have perhaps written an app or two. You should be familiar with basic types in the Swift standard library.
Covered concepts
This course focuses on:
- Protocol oriented programming
- Class dispatch
- Protocol dispatch
- Retroactive modeling
Let's review what you'll be learning in this course on protocol oriented programming in Swift, and why it's important.
Let's learn about how Swift gives you the ability to build polymorphic class types with different levels of dynamism.
Swift protocols can be used to provide customization points with default implementations in extensions.
Convert object oriented code to protocol oriented code and observe the key differences between the two.
In this video you'll see how protocols and retroactive modeling can be used as a tool for unifying types.
In this challenge, try using retroactive modeling to compute the bounding boxes for different shapes.
Protocol oriented thinking is nothing new but Swift provides a unique way to achieve reuse without requiring a specific data layout.