We’re looking at introducing Kotlin into our server-side project which has many teams. I’m looking for your suggestions in order to increase the chance of success and avoid some of the problems that are typically only realized with experience.
I’m especially interested in hearing from others that have introduced Kotlin to larger teams (as well as internal Kotlin usage at JetBrains) to see what conventions and best practices you have in place.
I’m looking for suggestions for the following areas:
- What language features do you try to avoid? (eg. “!!” not null assertions, do you avoid operator overloading for custom classes?)
- What language features do you limit the scope of ? (eg. How about using DSLs to enforce patterns? Do you limit the complexity that you allow for DSLs?)
- Do you have any conventions for how to organize the code? I’m especially curious about utility functions that would have typically been exposed as static functions. I’m also curious about extension functions. Do you prefer top-level functions or functions defined in companion objects. I’m also curious about namespace issues so I’m hoping that some conventions for organizing these should help. Do you mix & match Java & Kotlin files in the same directory or do you try to separate them?
- Since this is currently a Java project, it’s important for existing Java classes to be able to use the new Kotlin classes in a non-surprising / user-friendly way. What best practices help with this? Do you stick with the Java conventions of 1 class per file and classes being stored in the same package?
- What’s a good roll out plan to control the risk?
Although the answers to some of these questions may disagree with other opinions, I am genuinely interested in what practices you have in place for larger teams as it’s easier for us to relax the restrictions later as needed instead of the reverse.
We want Kotlin to be a success so I would really appreciate any comments and suggestions as well as any links to more information about conventions / best practices for Kotlin.