Inline classes are a new language feature in Kotlin and they are currently in alpha. Inline classes are simple wrapper classes that are optimized by the Kotlin runtime to avoid the performance hit of initializing a class. Let’s look at a few examples. This is a standard Kotlin class and is perfectly usable. However, classes are more expensive to initialize than fields. These classes have an especially high cost if you are wrapping a primitive, because primitives in Kotlin are heavily optimized by the runtime. This class wouldn’t get any of those optimizations. Alternatively we could just have the phone number be a property that lives in another class a la: Of course we now lose type safety and could[…]

I have been a huge fan of for years. I’ve recommended it to countless colleagues and whenever I want to learn anything about Android it is always my first resource. I’m am thrilled to announce that my first course, Refactoring Legacy Code is live on the site. The course is 30 minutes and has a total of 12 lessons. I have also published the source code for the course here. This course forks the Minimal-ToDo open source Android app. This is a real app on the play store but it hasn’t been updated or maintained in years. In the course I take old legacy code and convert it into a modern app. I use Room for storing data, an[…]

This is satire. On the 84th time I played the Thomas the Train Theme song for my sons I actually listened to the lyrics. My gut wrenched and beads of sweat formed on my thin, receding hairline. We all think of Thomas as a fun-loving character who serves his community in high stature. Nothing could be further from the truth. The proof has been right under our nose for years. We need not look further than the main verse of the theme song which I’ve broken down, line by line, below. 🎵 Thomas- he’s the cheeky one 🎵 Love the opener. Introducing the protagonist right off the bat. Letting the viewer know that this show is goofy. Our main character[…]