Re:SimCity’s Sims Don’t Seem That Smart After All
by skeoh on Wednesday March 13, 2013 @07:19PM
(#5371759)
Is it just me or are these 'yoda conditions' (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.
[ Parent
| on HN ]
Re:SimCity’s Sims Don’t Seem That Smart After All
by skore on Wednesday March 13, 2013 @08:09PM
(#5372105)
Major 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".
Re:SimCity’s Sims Don’t Seem That Smart After All
by skore on Thursday March 14, 2013 @07:16AM
(#5374232)
To stop people from upvoting me: I'm in the tabs camp. There, I've said it.
Re:SimCity’s Sims Don’t Seem That Smart After All
by lmm on Wednesday March 13, 2013 @08:43PM
(#5372323)
It's just you. Once you're used to them they're just as easy to read as "normal" conditionals, if not easier.
Re:SimCity’s Sims Don’t Seem That Smart After All
by rorrr on Wednesday March 13, 2013 @11:50PM
(#5372972)
No, 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 ...".
Re:SimCity’s Sims Don’t Seem That Smart After All
by loopdoend on Thursday March 14, 2013 @01:02AM
(#5373188)
This 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).