What would be a good package & file name for a...
# codingconventions
k
What would be a good package & file name for a set of String utility functions (top-level functions, some extensions, some non-extensions). I've used
package companyname.productname.utils
and filename
Strings.kt
but I'm looking for something more meaningful, descriptive and idiomatic.
y
I usually have a
utils
package and then the file is usully
StringExtensions
.kt
g
I would name it StringUtils. But usually I avoid to have generic utils for types like String since it creates pollution to the Ide, I mostly limit their access modifier.
k
I wanted to name it StringUtils too, but it's usually recommended to avoid having the same word in the class name that is also in the package name (in this case utils). The functions will only be visible if you import them, hence there's no pollution if you don't.
g
FYI: Ktor team has xxxUtils in the util package, for example : https://github.com/ktorio/ktor/blob/main/ktor-utils/common/src/io/ktor/util/CoroutinesUtils.kt . For the pollution I was mostly referring to the extensions but I'm using intelij so it can detect classes/funs without the need to actually import it first.
🙏 1