edrd
12/03/2021, 4:40 PMconst val
will never change. An enum member will never change. There's nothing to pay more attention here than any other symbol (maybe it should actually be the opposite, a top-level var
should have this convention because that can lead to issues -- although I think in this case it should also be prefixed with CODESMELL_
😁).
My guess is this convention came from Java, which came from C/C++, where developers reading macro usages should immediately know it would expand to arbitrary code, but this is not the case in Kotlin.ephemient
12/03/2021, 4:56 PMFor enum constants, it's OK to use either uppercase underscore-separated names (screaming snake case)) or upper camel case names, depending on the usage.(enum class Color { RED, GREEN }
edrd
12/03/2021, 6:36 PMPascalCase
.jw
12/03/2021, 7:08 PMlouiscad
12/03/2021, 7:33 PMRichard Gomez
12/06/2021, 8:24 PMScreaming case constants might communicate the fact that something is hardcoded, that's the only, very small benefit I found.It's also differentiated from Kotlin's convention of using PascalCase for functions and builders. e.g.
interface CoroutineScope
vs fun CoroutineScope
.
https://github.com/Kotlin/kotlinx.coroutines/blob/4724523601237c8a02abcbf337f5a13d934599c5/kotlinx-coroutines-core/common/src/CoroutineScope.kt#[…]7