Lilly07/21/2020, 3:59 PM
ResponsePacket is a interface because I have multiple packets which I want to offer, e.g.
val responsePacketsChannel = ConflatedBroadcastChannel<ResponsePacket>()
. Now I'm wondering what would be the proper way to differentiate between the specific packets when I start to observe them. My first thought was using
combined with an enum
Is there maybe a better solution?
val responsePacketsChannel = ConflatedBroadcastChannel<Pair<ResponsePacketType, ResponsePacket>>()
João Gonçalves07/21/2020, 4:02 PM
Lilly07/21/2020, 4:08 PM
Zach Klippenstein (he/him) [MOD]07/21/2020, 4:43 PM
on the actual packet type, which is much better than adding the abstraction of creating an enum to represent that. Enum doesn't add any type safety, and just creates more opportunities for bugs (eg incorrect mappings, more code to update for every change, etc).
Lilly07/23/2020, 9:43 AM
Zach Klippenstein (he/him) [MOD]07/23/2020, 3:40 PM