I had some hidden string formatting in one of my c...
# getting-started
c
I had some hidden string formatting in one of my classes, and now that I want to write a test for it, I pulled it out into it's own class. It's your typical "Should I create a StringUtils class?" sort of question. Should I have
Copy code
class StringUtil {
    fun getInitialsFromName(name: String): String {
or just create
Copy code
class InitialGeneratorService {
    fun get(name: String): String {
Or should it be a companion or just make a string extension method (seems easily abused though) I'm definitely overthinking it, but approciate any advice
b
Usually util function in kotlin either a top-level function (remove StringUtil class declaration and move your fun outside) or member of an
object
(use
object StringUtil {
)
a
in case that's a real example and not a fictional one, https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
2