https://kotlinlang.org logo
#compose
Title
# compose
g

grandstaish

11/20/2020, 1:12 PM
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

matvei

11/20/2020, 1:18 PM
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

grandstaish

11/20/2020, 1:21 PM
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

Louis Pullen-Freilich [G]

11/20/2020, 3:31 PM
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