Chapter 7: Flexible Code with Protocols, Generics, and Extensions
Seasoned programmers will (or should) know the core concepts of object-oriented programming (OOP). It's been around for a while, and it has shaped the way many of us develop and think about software. But a relatively new paradigm on the scene comes in the form of protocols with protocol-oriented programming (POP). Not intended as a replacement for OOP, POP has gained a lot of traction over the years, especially with the Swift community.
In this chapter, we'll learn everything we need to know about POP, from standard implementation to associated types and then onto generics. By the end of this chapter, you'll be extremely confident with not only implementing POP in your app, but also understanding what it has to offer.
The following topics will be covered in this chapter:
- Understanding and implementing protocols
- Getting the best out of extensions
- Adding flexibility with generics...