The title might sound weird at beginning since many modern libraries or tools are designed to make developers write less code via ways like code generation or reflection. Those libraries are great and convenient to use because we write less code. However in my experience sometimes developers become careless and misuse those libraries by calling them everywhere they could. Eventually the codebase becomes difficult to read and maintain. Here are some examples I have seen many times and would like to share with you.

Continue reading

In my previous post Kotlin “By” Class Delegation: Favor Composition Over Inheritance I covered using by keyword for class delegations. You can easily reuse and compose existing concrete implementations in your code. In this post I will be going over using the same by keyword for properties and how you can use them to create reusable code and reduce awkward boilerplate code. I will also include some Android specific samples with delegated properties.

Continue reading

Writing custom views or view groups is quite common nowadays, but sometimes it can be really cumbersome. You have to write overloaded constructors so that they would work properly in layout editor, or you define and implement some interfaces so that you don’t have to copy and paste the same code in different subclasses. With Kotlin we can easily avoid those common pain points when writing custom views and still enjoy full interoperability with Android!

Continue reading

Author's picture

Eric Lin

A software engineer who does Android, Server(less), and Kotlin development and enjoys learning new technologies

Software Engineer

Mountain View, CA