Member-only story

Kotlin Delegates

Learn about Different Delegates in Kotlin

Satya Pavan Kantamani
4 min readJul 17, 2020

Kotlin language is a pack of many awesome features. Once you start using the features of Kotlin you will understand them better. In this post, let's explore Kotlin Delegates and how to use them.

Introduction to Delegation Pattern

In software engineering, the delegation pattern is an object-oriented design pattern that allows object composition to achieve the same code reuse as inheritance — Wikipedia

We can say delegation is an alternative to inheritance however they both provide similar behavior. Both of them allow us to reuse the code but slightly in a different way. In some cases, we need to use delegates instead of inheritance

  1. Where a class is not designed for inheritance — like when a class is final, private, etc.
  2. When we only need some functionality from the base class rather than all

But we rarely see the implementation of Delegation as we are habituated with ease of using inheritance or lack of good support.

Delegation in Kotlin?

--

--

Satya Pavan Kantamani
Satya Pavan Kantamani

Written by Satya Pavan Kantamani

Android Dev, Interested in Traveling, App development. Based in Hyderabad, India. Catch me at https://about.me/satyapavankumar

No responses yet