Menu
Coddy logo textTech

Naming Conventions

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 10 of 93.

Naming conventions are a set of guidelines that developers follow to make their code more readable and maintainable. Different programming languages often have different naming conventions. In Kotlin, variables and values are written in camelCase: the first word starts with a lowercase letter, and each subsequent word starts with an uppercase letter.

When writing a variable name, be descriptive and use meaningful words.

For example:

fun main() {
    // Bad Naming
    val is_active = false // not camelCase (snake_case)
    val a = 10
    val b = "Hello"
    val x = true

    // Good Naming
    val age = 10
    val greeting = "Hello"
    val isActive = true
}
challenge icon

Challenge

Beginner

Write code that initializes the following values using proper camelCase naming:

  • playerName with the value "Alice"
  • playerAge with the value 25
  • isGameOver with the value false

Make sure you use the exact variable names and values. Remember:

  • Kotlin is case sensitive! (playerNamePlayername)
  • String values must be enclosed in double quotes
  • Boolean values are lowercase: true / false

Try it yourself

fun main() {
    // Type your code below
    val playerName = ?
    val playerAge = ?
    val isGameOver = ?

    // Don't change the lines below
    println("playerName = $playerName")
    println("playerAge = $playerAge")
    println("isGameOver = $isGameOver")
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Kotlin playground