DEV Community

Discussion on: Kotlin - The Good, the Bad and the Ugly

 
yuriykulikov profile image
Yuriy Kulikov

You can, of course, implement interfaces in data classes, but, in my opinion, compisition will always be a better way to do it. Want to avoid property duplication in your DTOs/value objects/whatever? Move the duplicated part to a new data class and use it as a property in another class. I have yet to see a use of inheritence which can be justified. Normally it is just a mess. Steer clear of it :-)