Hi Is it bad practice to have a parent interface ...
# announcements
j
Hi Is it bad practice to have a parent interface for common property of data classes ? I found this in stack overflow and wondering if there is a official documentation about ti https://stackoverflow.com/questions/26444145/extend-data-class-in-kotlin
c
To my knowledge, it is good practice to use interfaces with data class. In practice what doesn't work well with data classes is inheritance, but composition is completely okay (so polymorphism works well).
One of the issues with using interfaces and data classes is that your data class constructor will have to override all attributes of the interface, but I think that's fine.
👍 1
j
Thanks