[Medium article] Simple sample showing composition vs inheritance(using Kotlin delegates)
-
Updated
Jul 17, 2024 - Kotlin
[Medium article] Simple sample showing composition vs inheritance(using Kotlin delegates)
Kotlin supports “delegation” design pattern by introducing a new keyword “by”. Using this keyword or delegation methodology, Kotlin allows the derived class to access all the implemented public methods of an interface through a specific object. The following example demonstrates how this happens in Kotlin.
Observable delegation allows you to observe changes to a property and react to those changes. Basically it will work as changeValueListener.
In Kotlin, property delegation is a language feature that allows you to delegate the implementation of a property to another object. One type of property delegation is the lazy delegation, which allows you to delay the initialization of a property until it is actually used for the first time.
A simple app that implements Delegation design pattern in Kotlin
Add a description, image, and links to the kotlin-delegation topic page so that developers can more easily learn about it.
To associate your repository with the kotlin-delegation topic, visit your repo's landing page and select "manage topics."