Que os parece mejor?
Opción A
sealed class Category(val type: String) {
data class A(val description: Id, val value: Int) : Category("A")
data class B(val description: Id) : Category("B")
data class C(val value: Int) : Category("C")
}
Produce:
"category": {
"type": "A"
"description": "description of A"
"value": 4
}
Opción B
sealed class Category() {
data class A(val description: Id, val value: Int) : Category()
data class B(val description: Id) : Category()
data class C(val value: Int) : Category()
}
Produce:
"category": {
"description": "description of A"
"value": 4
}
Ponerse siempre el type a pesar de ser redundante?