Using Delegated Properties for Cleaner Code

Delegated properties in Kotlin allow you to delegate the responsibility of getting and setting a property to another object. This can help reduce boilerplate code and enhance readability. A common use case is using the `lazy` delegate for lazy initialization of properties, which ensures the property is only computed when accessed for the first time.

class User {
    var name: String by lazy {
        println("Computing name...")
        "John Doe"
    }
}

fun main() {
    val user = User()
    println(user.name) // Triggers lazy initialization
    println(user.name) // Uses cached value
}