Is it a good practice? ``` data class Property( ...
# announcements
t
Is it a good practice?
Copy code
data class Property(
    val name: String,
    val value: String
)

data class Element(
    val name: String,
    val properties: List<Property>?,
    val elements: List<Element>?  ---> REFERENCE ITSELF
)
d
Also I would just use a
Map<String, String>
instead of a
List<Property>
unless
Property
is a placeholder for something more complex than two strings.
You at-ed the wrong person. But I suppose that's true.
Generally something called "properties" can't / doesn't want to have duplicates though, which is why I added that.
h
Also a data class comes with field names for the "key" and "value" which is syntactically pleasing 😉
Instead of
entry.key
you have
property.name
which is more context.
I could have explained it better 🙃
When I use maps I always feel I have to write really verbose variable names
Copy code
val firstNameToNameOfFavoritePet: Map<String, String> = ...