Should instance independend methods be moved to companion object?

In Java I mark (private) methods, that are independent from an instance as static. This makes the independence obvious and I think it could be improve the performance, too (although it was never the reason to make methods static for me).

Now I wonder, whether it would be idiomatic to move such methods to the companion in Kotlin. If this would be the case, it could be added to the idioms page.

Currently moving a private method into companion and using it in the class itself would introduce some overhead, so it’s better not to, unless there’s another reason for that method to be in companion.

1 Like