Kotlin

Kotlin's Computed Properties Are Just Methods

But don't use them to make Observables

Ronald Martin

12 minute read

Bytecode generated in Android Studio

Note: this post assumes familiarity with Java language features and conventions. RxJava familiarity is useful, but not required. I was curious today about the relationship of Kotlin’s computed properties and methods. They do very similar things, so are they implemented similarly? (Spoiler: Yes. Yes they are.) Somehow, however, I also ended up drawing some conclusions on the semantics of reactive Observable generation. Kotlin’s computed properties can be a powerful tool for expressing your program’s intent with Observables, but you should think twice before using them for that purpose.

7 minute read

Update 2016-10-05 This article has been updated to reflect some changes to tooling that fixes some of the problems mentioned below. Living Life on the “Edge” I’m currently building an Android app to remind me to take healthy breaks from starting at computer screens. For extra funsies, it’s built on the cutting edge of current fashionable Android technologies. Of particular note today, we have: MVP architecture using Dagger 2 for dependency injection, and Kotlin, the JVM language by JetBrains.