Never miss a beat

Join my newsletter.

Tag: traits

Adapting Traits for Kotlin

Published: 4/10/2019

Traits are a pattern introduced in Scala (at least, this was my first introduction to them) that help avoid deep class hierarchies in favor of composition. If you don’t have Scala experience, but do have Java experience, you can treat this similarly to Java 8 Interfaces . However, I still prefer to call them Traits. Although Traits have first-class support in Scala, Kotlin does not directly have Traits. However, Kotlin does support default interface implementations , just like Java 8. It’s…