Some tips about code style, applicable to many languages but written in kotlin:
Naming: If there exists a class with a similar purpose in Java
SDK, then try to follow their naming style. e.g. if you write a
formatter of some kind, look up DecimalFormat
or DateFormat.
These classes have key methods parse and
format. Try to name your formatter similarly and include
the same methods. Additional tips in Java
naming conventions
On the other hand, do not the name class if it resembles a common
pattern that is not present in your code. For instance, a class should
not be named SomeBuilder if it doesn’t follow the Builder pattern
and sequentially doesn’t contain build method in
it.
Naming methods: There are 4 things that make the description of the method:
Refactoring conditional expressions: Conditional expressions should be on the same level of identation for better readibility:
// this; if-else on the same level
fun getCondition(condition: Boolean) =
if(conditional)
true
else
false
// over this; not clear at the first sight where is the corresponding if
fun getCondition(condition: Boolean) = if(conditional)
true
else
false