BestTechie Forums: Order Of Arguments In Expressions - BestTechie Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Order Of Arguments In Expressions How do people decide which order to use?


#1 User is offline   Aquafereion 

  • Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 08-November 07

Posted 08 November 2007 - 12:37 PM

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.

#2 User is offline   jcl 

  • UberTechie
  • Group: Linux Experts
  • Posts: 1304
  • Joined: 30-August 04
  • Location:The Internet
  • Operating System:Arch

Posted 08 November 2007 - 09:15 PM

View PostAquafereion, 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 User is offline   Tomm 

  • Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 22-December 07

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
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users