Careeroza
Naming Rules and Conventions
Rules
- Names can contain letters, digits and underscores, but cannot start with a digit.
- Names are case-sensitive:
totalandTotalare different. - Hard keywords (
val,fun,if,class,when...) cannot be used as names.
Conventions
| What | Style | Example |
|---|---|---|
| Variables and functions | camelCase | cartTotal, getUserName() |
| Classes | PascalCase | OrderSummary |
| Constants | UPPER_SNAKE_CASE | MAX_RETRY |
| Packages | lowercase | com.careeroza.app |
Example
Good names make code read like a sentence.
fun main() {
val deliveryPartnerName = "Ramesh"
val etaMinutes = 12
val isOrderPicked = true
println("$deliveryPartnerName picked the order: $isOrderPicked, ETA $etaMinutes min")
}Output
Ramesh picked the order: true, ETA 12 min