September 2019
Intermediate to advanced
462 pages
11h 3m
English
Both inheritance and delegation, which are distinctive design tools in OO programming, promote reuse by way of extending one class from another. We have to wisely choose between them. Languages’ capabilities often limit our choices, and this is where Kotlin’s ability to support both comes into play.
While powerful and often used, inheritance—where a class derives properties, methods, and implementation from another class—leads to tight coupling and is inflexible. Most languages that provide inheritance don’t permit a class to choose between different base classes. Whatever a class inherits from, you’re stuck with it, like biological parents—whether you like them or not, you don’t have a choice.
Delegation ...
Read now
Unlock full access