aspose file tools*
The moose likes Java in General and the fly likes Coding standard - condition order in if statement. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Coding standard - condition order in if statement." Watch "Coding standard - condition order in if statement." New topic
Author

Coding standard - condition order in if statement.

Janne A Andersson
Greenhorn

Joined: Mar 18, 2003
Posts: 2
Hi,
is there any reason why

would be considered better then

I can't really see it being cosmetical reasons, but I could be wrong...
thanks Jan
Janne A Andersson
Greenhorn

Joined: Mar 18, 2003
Posts: 2
Got an answer,
it comes into play when you do an equal-test (==), to prevent accidental assignment. With a not equal test it doesn't add anything, more to keep up the habit and for consistency reasons i guess...
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yup. See also this thread.


"I'm not back." - Bill Harding, Twister
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Coding standard - condition order in if statement.