23 Protocol Extensions
The dominant software design philosophy of the past few decades has been object-oriented programming (OOP). OOP is powerful and well known; people have an intuition for what this style means for code. Traditionally, OOP uses classes to model data and methods to modify the properties on instances of those classes and to communicate with instances of other classes. Swift supports OOP, though its approach is often not idiomatic in that enums and structs can replace many typical uses of classes in OOP.
Swift also addresses some of OOP’s flaws. In OOP, inheritance, in particular, has to be used with great care. It is easy to end up with a code base full of difficult-to-understand classes due to a deep inheritance ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access