This is perhaps "just" a style question; however, even for matters of style that fall into the 'personal preference' category, there must be a rationale. (Mustn't there?)
I am interested in why, given a variable, an operator and a value, people choose to write either
if (variable operator value) -- e.g., if (myItn == 0)
or
if (value operator variable) -- e.g., if (0 == myInt)
I have a strong personal preference on this matter, for which I have a well-thought-out rationale and from which I never vary, and although I have seem many examples of the opposite order, I have never been apprised of the rationale for it.
Which order is your choice, and why?
Thanks in advance for your response.
Page 1 of 1
Order Of Arguments In Expressions
How do people decide which order to use?
Tweet
#2
Posted 08 November 2007 - 09:15 PM
Aquafereion, on Nov 8 2007, 09:37 AM, said:
if (variable operator value) -- e.g., if (myItn == 0)
Usually reads more naturally.
Quote
if (value operator variable) -- e.g., if (0 == myInt)
Catches ==/= typos.
Quote
Which order is your choice, and why?
The former. Prefer the way it reads, never had trouble avoiding typos, often use assignment in conditionals.
This post has been edited by jcl: 08 November 2007 - 09:36 PM
#3
Posted 30 December 2007 - 06:01 PM
I use variable operator integer. I believe this stems from my days of Algebra, where we HAD to write our answers like X=4.
Page 1 of 1

Sign In »
Register Now!
Help

Back to top
MultiQuote