Composition vs. Inheritance: Alternative to Protocols | Swift & iOS Basics

Composition vs. Inheritance: Alternative to Protocols | Swift & iOS Basics

716 Lượt nghe
Composition vs. Inheritance: Alternative to Protocols | Swift & iOS Basics
In software development, the choice of design principles significantly impacts the maintainability, scalability, and flexibility of a codebase. Protocols (or interfaces) are a powerful tool which gives developers the freedom to introduce, update, refactor, or replace individual components without risking to destabilize the system at large. But protocols aren’t the only way to achieve that degree of flexibility. In addressing specific challenges, other mechanisms turn out to be a better choice. Inheritance is one of such alternatives. It is a key concept in object-oriented programming, and in this video, I’m delving into why alternatives might be necessary, and comparing the approaches. Support the Swift Bird by… • …joining as a member: https://www.youtube.com/channel/UC3mDnPzYxvKHaMLANaiDDYQ/join • …becoming a patron: https://patreon.com/SwiftBird • …buying me a coffee: https://www.buymeacoffee.com/SwiftBird Links: • Next episode: https://youtu.be/wNBMREoL14k • Swift & iOS Basics playlist: https://www.youtube.com/playlist?list=PL1YFPH8CuCKbeaBz_zrFxKh0cqYT5T2fD • Text version: https://yakovmanshin.com/2025/02/composition-vs-inheritance/ • Composition over inheritance: https://en.wikipedia.org/wiki/Composition_over_inheritance • Composition vs. Inheritance: https://www.digitalocean.com/community/tutorials/composition-vs-inheritance • Liskov substitution principle: https://en.wikipedia.org/wiki/Liskov_substitution_principle Chapters: • 0:00 Intro • 1:22 What Is Composition? • 3:06 Why Alternatives Might Be Needed • 4:25 Inheritance: An Alternative Approach • 7:23 Benefits of Inheritance • 10:02 Drawbacks of Inheritance • 12:58 How to Choose • 15:54 Summary The Swift Bird, a Yakov Manshin production 🎞️ #composition #inheritance #softwaredevelopment