Optimize naming and structure for readers
Consistent formatting reduces distractions; meaningful names and small contracts reduce the reasoning a reader must do. Prefer domain names over abbreviations, and make units explicit when primitive values could be confused.
data class StudySession(val topic: String, val durationMinutes: Int)
fun totalMinutes(sessions: List<StudySession>): Long =
sessions.sumOf { it.durationMinutes.toLong() }
The names distinguish minutes from milliseconds. A Long accumulator avoids ordinary Int total overflow. Explicit public return types document the API while local inference keeps implementation readable.
Follow Kotlin's official conventions for declarations, indentation, wrapping, and naming, then let a formatter enforce the mechanical parts. Do not compress complex control flow into one expression merely because Kotlin allows it.
Exercise
Review a function with names such as x, data, and process. Rename them according to domain meaning, add units, and split unrelated side effects into explicit operations.
Check: a reviewer should understand what the function returns and which state it changes without stepping through every line.