Search⌘ K
AI Features

Introduction to Delegation

Discover the advantages of delegation over inheritance in Kotlin. Learn how Kotlin supports delegation for flexible design and code reuse, understand when to choose delegation instead of inheritance, and get introduced to built-in delegates that enhance property handling.

We'll cover the following...

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 ...