5 ms·
At first glance this looked like a code smell, but after some reflection I can't think of a cleaner, more readable way to uniquely identify each possible relat
by TimTheTinker 7y ago
At first glance this looked like a code smell, but after some reflection I can't think of a cleaner, more readable way to uniquely identify each possible relationship -- especially in a strongly-typed language with an IDE.
Here's the full list: https://developer.apple.com/documentation/contacts/contacts_constants https://developer.apple.com/documentation/contacts/contacts_...
- bayonetz 7y agoAmen. Sometimes it takes what it takes to be precise.
- c3534l 7y agoYou need an intermediate representation (like a tree) rather than attempt to brute force every possible permutation up until some arbitrary point. Even if that weren't the case, it'd be better to give it a more obscure name or create some kind of naming system and then document it rather than demonstrate why self-documenting code can become self-defeating if taken to an extreme.
- masklinn 7y agoThe issue of a tree is you could trivially create nonsensical relationships. An alternative would be some sort of nested attributes / tag set but even that's not excellent. A second issue is, this is probably a localisation / cultural concern: below, yorwba notes that this relationship is a specific term in chinese kinship: https://en.wikipedia.org/wiki/Chinese_kinship#Common_extended_family_and_terminology https://en.wikipedia.org/wiki/Chinese_kinship#Common_extende....
- sansnomme 7y agoAnd generate the list using metaprogramming at compile time.
- jug 7y agoNot sure, but I sort of expected this monstrosity happens because the labels are intended to be localizable.
- ulrikrasmussen 7y agoWhy would an obscure name be better? This looks like an example where a very specific relationship is needed, and the name specifies precisely what that is. Choosing an obscure name for this feels like an attempt to hide the fact that this is a special case by using vague terminology.
- stevekemp 7y agoTrees can't be used for relationships, due to the crazy things that people can do with each other. You'll need a DAG, and you'll need to detect cycles. https://stackoverflow.com/questions/6163683/cycles-in-family-tree-software https://stackoverflow.com/questions/6163683/cycles-in-family...
- masklinn 7y agoHere's the likely explanation for these: https://en.wikipedia.org/wiki/Chinese_kinship#Common_extended_family_and_terminology https://en.wikipedia.org/wiki/Chinese_kinship#Common_extende...
- deleted 7y ago[deleted]
- tqkxzugoaupvwqr 7y ago`Colleague` in `CNLabelContactRelationColleauge` is spelled incorrectly.
- floatingatoll 7y agoIf you have a macOS or iOS beta installed, please report that through the Feedback app on either?
- bildung 7y agoWhy on earth would someone do bug fixes for free for a corporation that has cash reserves of $250 billion but is too stingy to pay for quality control?
- floatingatoll 7y agoBecause otherwise thousands of developers will have to see that typo for the next ten years.
- Intermernet 7y agoLike "Referer" :-) https://en.wikipedia.org/wiki/HTTP_referer#Etymology https://en.wikipedia.org/wiki/HTTP_referer#Etymology
- bildung 7y agoBut by fixing it yourself, aren't you effectively training the corporation to stay sloppy? Sure, this bug is fixed right now. But a year down the road, when the staff count for quality assurance gets renegotiated, the position to deliver quality out of the box gets weakened, resulting in even more bugs of this kind.
- jperry 7y agoThis is slightly absurd. It's reporting a very minor bug, not offering to implement a whole feature. Are you saying that no-one should report anything because it encourages them to let bugs slide into production?
- zoul 7y agoI still don’t think this is a good solution because of the common CNLabelContactRelation prefix. It would be better to introduce a CNLabelContactRelation enum? Then the enum cases would be much less painful. Or at least an empty enum as a namespace: enum CNLabelContactRelation { static let aunt = "…" static let auntFathersBrothersWife = "…" }
- umanwizard 7y agoIn Objective-C (and C), enum members are unscoped. So in your example "aunt" would be in the global namespace.
- brianpgordon 7y agoA pretty idiomatic (and trivial to implement) Scala way of doing this would be to have a DSL with a name for each relation and compose them together using function application. So to express "MothersSiblingsDaughter" you'd write "mother sibling daughter". The whole expression would return an object which contains a linked list of the individual components, consed together by each individual function application in the chain. Of course, this is kind of co-opting the call stack to build up at runtime what the compiler can already provide as an AST, so it might be better to just use a macro. This representation can't be serialized quite as easily as a single symbol or whatever Apple is doing, but it is infinitely flexible. And it seems like a code smell to me that they have a special case for the father's brother, while the mother only has a generic "sibling." It should be up to the view layer to determine that kind of localization-specific logic. If you just store a completely arbitrary relation then you can punt it to the localization to decide how to translate that into meatspeak.
- toxik 7y agoAs noted elsewhere, this is more than likely for localization which composing would not enable. Would also explain the asymmetry, does it match Chinese? https://en.m.wikipedia.org/wiki/Chinese_kinship#Common_extended_family_and_terminology https://en.m.wikipedia.org/wiki/Chinese_kinship#Common_exten...
- stillworks 7y agoWould it not be better to just allow the user to label the relation the way they want and only give options for some most common(important?) ones ?