Naming Conventions in Kotlin

Halil Özel
2 min readAug 24, 2024

Kotlin offers a strong type system and a clear naming syntax similar to Java. This ensures code readability and maintainability.

Kotlin Naming Conventions

Variable and Constant Naming

  • camelCase: The first letter is written in lower case, and the first letter of each subsequent word is written in upper case.
    Example: ourVariable, numberOfTeams
  • Constants: All upper case and words are separated by ‘_’.
    Example: PI, MAX_VALUE
val myName = "Halil" // Variable
const val PI = 3.14159 // Constant

Function Naming

  • camelCase: The first letter is written in lower case, and the first letter of each subsequent word is written in upper case.
  • Begins with a verb: It begins with a verb that expresses what the function does.
  • Example: calculateArea(), findMin()
fun calculateArea(length: Int, width: Int): Int {
return length * width
}

Class and Object Naming

  • PascalCase: The first letter of all words is capitalized.
  • Abstract names for abstract concepts: Must clearly express the concept that the class represents.
  • Example: Team, Book, Database
class Person(val name…

--

--