Using \"m\" prefix for variable names became usual in programming, mainly in Android, but since Kotlin arrived, this minor thing bothers me a bit.
Setting and getting va
I actually don’t think it’s good practise to have prefixed variables in the public API, thus foo.mName = "Foo"
would be undesirable. For private fields this would be acceptable though.
The official conventions for the Kotlin language say:
Names for backing properties
If a class has two properties which are conceptually the same but one is part of a public API and another is an implementation detail, use an underscore as the prefix for the name of the private property:
class C {
private val _elementList = mutableListOf<Element>()
val elementList: List<Element>
get() = _elementList
}
Per the Android Kotlin Style Guide:
Special prefixes or suffixes, like those seen in the examples
name_
,mName
,s_name
, andkName
, are not used except in the case of backing properties (see “Backing properties”).
Therefore you should not use the "m" prefix for variables in Kotlin.
A good reference from Android
https://android.github.io/kotlin-guides/style.html
Special prefixes or suffixes, like those seen in the examples name_, mName, s_name, and kName, are not used except in the case of backing properties (see “Backing properties”).