What is naming convention for a file with Kotlin extensions?

156 Views Asked by At

I have generated class MyDto and I want to add couple of new functions

fun MyDto.convert(foo: String): Bar {...

I have no choice - I have to put it to different file but in contrast to java it won't be a class but just a Kotlin file.

How should I call it ?

MyDtoUtils.kt or myDtoUtils.kt ?

Is there any convention for that ?

1

There are 1 best solutions below

1
NirYudo On BEST ANSWER

As written in the Coding conventions from kotlinlang.org

If a file contains multiple classes, or only top-level declarations, choose a name describing what the file contains, and name the file accordingly. Use an upper camel case with an uppercase first letter (also known as Pascal case), for example, ProcessDeclarations.kt.

So from that, I think you should go with MyDtoUtils.kt