Post

I'm making a conference talk with the title "Bad Kotlin Advice". Dear #Android and #Kotlin community, you know what to do. Reply with the worst Kotlin code possible. :)

8 reposts31 likes

val result = listOf("apple", "banana", "pear", "apple", "kiwi") .distinct() .sortedBy { it.length } .map { it.uppercase() } .take(3) .joinToString(",") It works, but it is harder to read

- Extension functions on common types like String polluting your entire codebase - funky operator overloads - invoke operator on companion to fake constructor - using coroutines - x?.let{}:?run{} - using lazy without changing the synchronization pattern

I'd say an over use of extensions in general. This is the one thing that makes Compose annoying to work with. Everything is an extension function/property, so everything is 10x clunkier than it should. Especially when also using copilot.

Regarding extension functions. I once saw this: val String.charFlow: Flow<String> get() = flow { split("").forEach { emit(it) } } .filter { it.isNotEmpty() }