Menu
Coddy logo textTech

Naming Conventions

Part of the Fundamentals section of Coddy's Swift journey — lesson 9 of 86.

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 Swift, variables and constants 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:

// Bad Naming
let is_active = false // not camelCase (snake_case)
let a = 10
let b = "Hello"
let x = true

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

Challenge

Beginner

Write code that initializes the following constants 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:

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

Cheat sheet

In Swift, variables and constants follow camelCase naming convention — the first word starts with a lowercase letter, and each subsequent word starts with an uppercase letter.

Use descriptive and meaningful names for your variables and constants:

// Bad Naming
let is_active = false // not camelCase (snake_case)
let a = 10
let b = "Hello"
let x = true

// Good Naming
let age = 10
let greeting = "Hello"
let isActive = true

Try it yourself

// Type your code below
let playerName = ?
let playerAge = ?
let isGameOver = ?

// Don't change the lines below
print("playerName = \(playerName)")
print("playerAge = \(playerAge)")
print("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