I have published a post or two about the powers of brevity. But we programmers sometimes take it too far.
Can someone tell me what these integers represent?
case upc(Int, Int, Int, Int)
No? Me either.
This is how associated values are pretty much always done in Swift. But thanks to this post by Marco Eidinger via iOS Dev Weekly, I discovered something new and clarifying: it turns out that you can actually label your enum’s associated values too. People just don’t do it for some reason. π€·π»ββοΈ
Can you tell me what the integers represent now?
case upc(numberSystem: Int, manufacturer: Int, product: Int, check: Int)
Isn’t that a little easier to understand?
I run into the assumption sometimes where people mistake brevity for efficiency. Brevity shouldn’t mean sacrificing valuable context for slightly fewer words. Thanks to the Marco Eidinger post for pointing this out explicitly. π
Clarity is more important than brevity.
Marco Eidinger