Hey, which option do you think is better, or maybe...
# codingconventions
c
Hey, which option do you think is better, or maybe you have another idea? a) Option A
Copy code
class DoSomethingUseCase {

    fun handle(command: DoSomethingCommand) {
        TODO("not yet implemented")
    }
}

data class DoSomethingCommand(
    val someValue: String
)
b) Option B
Copy code
class DoSomethingUseCase {

    fun handle(command: Command) {
        TODO("not yet implemented")
    }

    data class Command(
        val someValue: String
    )
}
🅰️ 2
c
Where the ’Command` types are used primarily by the use case have generally nested them (your Option B) to reflect that coupling. There are times where some of those nested types evolved have a slightly wider audience, at which point will move them out as a top level class to stand on their own.
j
I don't like to nest unless the inner class needs access to the outer object's state (very rare)