3 ms·
I think you're reading too much into 'confusing'. It won't leave someone without understanding; it -may- cause them to momentarily pause, going "WTF?...uh...pro
by lostcolony 11y ago
I think you're reading too much into 'confusing'. It won't leave someone without understanding; it -may- cause them to momentarily pause, going "WTF?...uh...probably does ~this~. But why would someone do things this way?" That's still delaying them, that's still distracting them, that's still putting up an obstacle. Not one a future maintainer can't overcome, but -why do it-? That's the point.
- the_af 11y agoIt seems like a reading micro-optimization to me, though. Surely most of the delays in understanding code lie in things other than "Yoda" conditionals. I'm going to guess complexity elsewhere in the code (even conceptual difficulties, such as "what is the purpose of this at all?") dwarf minor details like how one writes conditionals. If so, what is the point of this piece of advice?
- mreiland 11y ago> It seems like a reading micro-optimization to me, though. It's a "reading micro-optimization" in the same way that not littering your code with comments is a "reading micro-optimization". It makes you pause and interrupts your flow of thought as you contemplate something not directly related to what you were modeling in your head 2 seconds ago.
- the_af 11y agoI don't think it's the same. I'm not arguing against code cleanliness or good practices. Code readability matters. I favor concise, expressive languages over verbose ones for precisely this reason. Littering your code with comments IS a huge readability problem. You are forced to filter them out to find the real code, since they are mostly garbage, but you can never be sure you aren't skipping some vital bit of information. Likewise, boilerplate and needless ceremony obscure the intent of the code, so they are obstacles to be reduced in good, clean code. Contrast this with writing Yoda conditions. They are no big deal. They interrupt your flow of thought exactly once: the first time you encounter them. If your train of thought is interrupted every time you encounter them, you are way too novice a programmer. So I think this is a really minor issue in the sea of software complexity; so minor, in fact, that it seems bizarre to me to mention it. I think whether to use Yoda conditions, much like the placement of braces or the number of whitespaces for indentation, are the stuff of flamewars and endless argument because they are the kind of things we programmers love to obsess about, but they are really not very important.
- mreiland 11y ago> If your train of thought is interrupted every time you encounter them, you are way too novice a programmer. You're unimaginative. This conversation is finished.
- dang 11y agoThis comment breaks the HN guidelines. If you don't have something civil and substantive to say, please don't post. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- mreiland 11y agoplease stop following me around dang. One would think you would be warning the person who implied I was a novice programmer, but that would require consistency and fairness. either ban me or leave me alone until I do something that's actually ban worthy please. And to be clear, so there is no confusion here. Your guidelines state the following: > When disagreeing, please reply to the argument instead of calling names. E.g. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3." According to your guidelines, his comment: > If your train of thought is interrupted every time you encounter them, you are way too novice a programmer. Should have been something such as: > If your train of thought is interrupted every time you encounter them you probably don't see yoda conditionals very often. Please, do me favor, go warn him as well. consistency and fairness. Or just ban me since we both know that's what you want to do.
- the_af 11y agoI apologize if I offended you. I didn't mean "you" as in "you, mreiland", but as in a generic "you". I can no longer edit my post, but I've no problem if an admin edits that part to make it more explicitly general. My use of "you" was the same as yours when you said "it makes you pause and interrupts your train of thought"; I didn't take it to mean you were referring to me specifically! Unfortunately written language is prone to this kind of misunderstandings :(