Skip to content

Code guidelines

Ivan Schütz edited this page Mar 23, 2020 · 11 revisions
  • Use Kotlin.
  • Keep it simple!
  • Short functions and classes.
  • Try to minimize side effects and prefer pure functions.
  • Avoid force unwrap (!!) and lateinit. If needed, use ?: throw Exception("Meaningful message").
  • Use extensions.
    • If they are shared, put them in a file <ClassName>Extensions (e.g. TextFieldExtensions.kt)
    • If they are specific to a class/file, make them private.
  • Idiomatic Kotlin (let, apply, also, etc.). But keep readability in mind! Often a simple if != null is better.
  • Prefer composition over inheritance.
  • Prefer immutability.
  • Readable names.
  • If something is difficult to understand, add some documentation.
  • Use Rx in services / repos / business logic / view models and live data only to interface with the UI.
Clone this wiki locally