3 ms·
Is it just me or are these 'yoda conditions' (http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html http://www.codinghorror.com/blog/2012/07/new-
by skeoh 14y ago
Is it just me or are these 'yoda conditions' (http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html http://www.codinghorror.com/blog/2012/07/new-programming-jar...) confusing and difficult to read? They make sense but it's so jarring to see that I have to read the condition twice to be sure I understand it.
- skore 14y agoMajor code smell for me as well, but I've seen some rather big projects do them, so I always file it under "tabs vs. spaces".
- skore 14y agoTo stop people from upvoting me: I'm in the tabs camp. There, I've said it.
- lmm 14y agoIt's just you. Once you're used to them they're just as easy to read as "normal" conditionals, if not easier.
- rorrr 14y agoNo, it's not just him. Yoda conditions are hard to read, because they don't follow the natural language. You don't say "If 5 dollars is more than what I have...", instead you say "If I have less than 5 dollars ...".
- loopdoend 14y agoThis is a result of the code being transpiled from their scripting language and run through Google's Closure Compiler. You'll get the same behavior on conditions if you try it out (http://closure-compiler.appspot.com/home http://closure-compiler.appspot.com/home).