Is there a reason why `DefaultSwitchColors` (and s...
# compose
g
Is there a reason why
DefaultSwitchColors
(and similar colour interface implementations in the Material library) don’t use `data class`es and instead manually implement equals/hashcode?
m
Yeah, what Harsh said! Jake wrote a good article about it: https://jakewharton.com/public-api-challenges-in-kotlin/
👀 1
If there's a possibility that we might need to add more members to the class -- better make it non-data 🙂
g
But
DefaultSwitchColors
isn’t a part of the public API, it’s private
The article is really interesting, thanks! Good to know why `data class`es are avoided in general in published libraries
l
Yep, the binary compatibility reasons are important for public API. In this case, using data classes would just add a bunch of methods to the published libraries that we don't need, so we might as well save some method count and bytes if we can.
👍 1