Static imports can be bad for code readability. Fo...
# announcements
c
Static imports can be bad for code readability. For example, I've had a misfortune to deal with a code base with these collection "literals" all over it:
of(a, b, c)
, where
of
was a static import of
ImmutableList.of
,
ImmutableSet.of
etc. You always had to look at the imports to understand the code. Arguably that's a naming/misunderstood intention problem though, Google Collections' team obviously intended
*.of
not to be statically imported.
n
So the Kotlin convention to use top level functions avoids even that pitfall.
E.g. listOf(1, 2, 3) vs setOf(1, 2, 3)
c
Yup 🙂 Although I have no doubt, that people calling using
of(1,2,3)
in Java will happily commit the same atrocity in Kotlin
n
😄