6 ms·
If your class is called FooOrBar then you are bad at naming things.
by victor9000 5y ago
If your class is called FooOrBar then you are bad at naming things.
- 317070 5y agoNot necessarily. If your code is in English, and your category does not exist in English (like this Chinese word described here), then I do not see how to do better than this salad. How would you have named this class?
- macleginn 5y agoOne option (not necessarily a better one) is to use standard notation for kin relationships that basically show how to traverse the tree starting from ego: https://www.kintip.net/index.php?option=com_content&view=article&id=35&Itemid=202&limitstart=3 https://www.kintip.net/index.php?option=com_content&view=art...
- Jcowell 5y agoFamily trees are not trees but graphs.
- malka 5y agoacyclic graphs, hopefully
- dankent 5y agoSee the German TV show Dark for in interesting take on what could happen if they somehow became cyclic.
- mrlonglong 5y agoSeconded! Quite bizzare it was, a fun bingeing session a few years back.
- jfk13 5y agoSee also https://en.wikipedia.org/wiki/I'm_My_Own_Grandpa https://en.wikipedia.org/wiki/I'm_My_Own_Grandpa
- naniwaduni 5y agoWell, family graphs including relationships by marriage and adoption are not in general acyclic.
- LudwigNagasena 5y agoI don’t see how it would help to dispose of “or”. It would just make it less readable.
- karatinversion 5y agoWhile wordy, the class name is representing a real relationship that users care about. The developer could have borrowed the underlying word from e.g. Mandarin, but then it would be weird to use that when set to Cantonese.
- marcellus23 5y agoOr maybe it’s worth taking a couple seconds to understand the problem domain before judging someone else’s code.
- berkes 5y agoRegardless of the domain: classes with And or Or in them are at the very least a codesmell. Because the name even implies it does more than one thing (SRP)
- singlow 5y agoOr it represents one real thing that has multiple purposes outside the code and so the code can't fix that.
- berkes 5y agoTrue. But I've honestly never encountered this. Not in a valid domain concept. Where "valid" means it is truly embedded in the domain: and not some historical artifact that has been carried along for far too long¹ I'd love to see what valid real-world use-cases there are for an "FooOrBar" or "BarAndFoo" domain concept. -- ¹ Which is a conundrum, I know. If some legacy system or even legacy software was badly designed (or not designed at all, but just evolved over time) carries along its "design flaws", after so many generations or iterations, it becomes the domain concept itself.
- Anon1096 5y ago> But I've honestly never encountered this Boy do I have the perfect example for you then: https://developer.apple.com/documentation/contacts/cnlabelcontactrelationyoungercousinmotherssiblingsdaughterorfatherssistersdaughter https://developer.apple.com/documentation/contacts/cnlabelco...
- berkes 5y agoand, as many people pointed out, the actual domain concept is in Mandarin, and a single word. So a perfect example of the word "Or" that does not denote a logical disjunction but a translation-artifact. I thought it was obvious that it is not literally implied the letters O and R are never allowed after each-other in code. I mean: obviously having a class named OrGate in an electronics simulation is fine. As is OrParty in a system modeling Israelian politics. This is about the word Or denoting that your class, value, type, variable, model etc, is One Or The Other.
- LudwigNagasena 5y agoNot much you can do when you have a semantic gap in your language.
- glxxyz 5y agoIt's not a class, it's a variable. If another language uses the same word for their aunt or uncle, a decent way to represent that in English is `AuntOrUncle`. If the word 'Sibling' didn't exist, `BrotherOrSister` could be used instead.