Issues and alternatives
Implementation inheritance is controversial among OOP programmers and theoreticians. For instance, the authors Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm, of the book Design Patterns: Elements of Reusable Object-Oriented Software, advocate interface inheritance instead of implementation inheritance and recommend preferring composition over inheritance.
For example, the decorator pattern (as stated previously) has been proposed to overcome the static nature of inheritance between classes.
Furthermore, the OOP community agrees that inheritance introduces unnecessary coupling and breaks encapsulation, so modifications to the super classes can cause undesirable behavioral changes in subclasses.
In Swift, ...
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