When writing object-oriented code, we generally want to leverage inheritance and composition to reuse code, make relationships more flexible, and more efficiently model our data. In this section, we'll explore interfaces, abstract classes, and delegates and how they help us to implement the concepts of inheritance and composition.
Achieving inheritance and composition
Interfaces
Like in Java, we can define interfaces in Kotlin that can be used to define a common functionality or provide class templates. Similar to Java 8, interfaces in Kotlin may define default method definitions. Kotlin also provides the ability to define interface properties, which can either be abstract or can include a default implementation.
...