Converting 8+k lines of Java POJOs to Kotlin
Date : 27/MARCH/2020 Time : 15:00
At the moment, converting Java code to Kotlin is one of Doist’s engineers’ favorite tasks! We know and love all the benefits Kotlin brings us (conciseness, readability, safer null handling, etc). However, there are a few caveats that might be overlooked or things we take for granted in this process.
Our main product, Todoist, had a complex hierarchy of Java POJOs used to parse the API responses, local DB models, along with a few other utilities. All this added up to a total of over 8k LOC.
We’ve recently decided to modernize that part of our system by converting it all to Kotlin.
We had a few requirements to consider this refactoring successful:
- Ensure these models were usable in both Android and JVM-only projects;
- Ensure that an open-source version of these POJOs was still available to the community that wanted to do something related to Todoist
- Ensure we got additional benefits from it - just reducing the number of LOC wasn’t a plausible justification for such an endeavour. It ended up taking about 2 months from the beginning of the implementation to the complete stabilisation in production, passing by testing and code review;
This talk will highlight the process we’ve adopted, the lessons we’ve learned and some other interesting takeaways. The goal is that you know how to deal with similar cases in the future and, most importantly, be aware of Kotlin’s quirks and features and leverage them in the best way possible.