Protocols in Swift are similar to interfaces in Kotlin and some other languages. Although both protocols and interfaces relate to the concept of inheritance, they differ in key ways. Protocols offer a powerful way to structure your apps, abstract away from external dependencies and simplify both testing and code organization.
In this module, you’ll learn the fundamentals of protocols and how to use them in your apps. You’ll see how to define them, how to implement them and how they provide a similar role to inheritance at a very high level. You’ll also learn about the differences that separate the two concepts.
Along the way, you’ll learn how to use some of the features of protocols in Swift, like composition, to build complex types that aren’t possible with inheritance. Finally, you’ll have the opportunity to use protocols in a SwiftUI app.
Protocol-Oriented Programming, or POP, takes the protocol concept and applies it to a design pattern for your software. POP makes it easy to integrate third-party dependencies, write testable code and build apps that are easy to maintain.
See forum comments
This content was released on Oct 17 2023. The official support period is 6-months
from this date.
In this lesson, you'll learn what protocols/interfaces are, how to use them and how they compare to object-oriented programming. You'll also learn what Protocol-Orientated Programming is and how to use it to write better code.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.