What is the preferred naming style for a factory f...
# announcements
a
What is the preferred naming style for a factory function? Is it better to start names from uppercase or lowercase letters? I have found the following in Kotlin Coding Conventions:
Exception: factory functions used to create instances of classes can have the same name as the class being created
But what is the recommended style?
n
as a factory function i usually put
invoke
on the companion object
a
Thanks but I don't really like such an approach because: 1. such overloaded
invoke
operators do not appear in auto-complete, 2. you don't always have access to a class/interface, 3. I don't like to pollute interfaces with any implementation details. Currently I prefer to put factory functions into a separate file but struggling with naming. That's why I raised this question.
k
If they don't do a lot of work and have functionality obvious from the signature I think having top level functions with the same name is fine. If they need a better name or do IO or something like that I'd given them better names.