Does idiomatic Kotlin use classes to organize code...
# getting-started
j
Does idiomatic Kotlin use classes to organize code or is that a relic of my Java background? Specifically, is it good form to group related stateless functions in a class's companion object, or is it better to use a sub-package?
l
I would say: don't create a class just to have a companion. In that case, define the functions directly in a file. I would only define functions in a companion if it makes sense semantically to call it via the class name. Maybe something to keep in mind is that the Kotlin team is working on a namespace feature which is probably what you want
l
I’ve found that I use objects a lot more than classes after switching to Kotlin.
j
Thanks!