Search code examples
kotlinnaming-conventionsnaming

Is there a good practice to name kotlin file contains only functions?


For example i have a kotlin file with validation functions. Another example is a file with only one function which gets mobile device data (manufacturer, android version, etc.)

I have some thoughts to name it like for validation functions ValidationUtils.kt or ValidationFunctions.kt, Validations.kt, ValidationFun.kt, and for second example DeviceDataUtil.kt, DeviceDataProvider.kt (it sounds like a class name), DeviceDataGetterFun.kt.

I think they all suck. Can u help?


Solution

  • Generally speaking, the four basic kinds of modules in modular programming languages are

    1. Package of functions (no state)
    2. Abstract Data Structure (state with one instance)
    3. Abstract Data Type (state with several instances)
    4. Class (state with several instances and polymorphism)

    What you describe is an example of the first kind. One sensible convention is to use an abstract noun which describes the concept, so simply Validation would be a good choice. If you had a collection of mathematical functions you would name it Math and so on.