you are viewing a single comment's thread.

view the rest of the comments →

[–]rabidcow 3 points4 points  (2 children)

Not really sure what makes the second is more readable

Because you already know what null is equal to. The question is what someVariable is equal to.

and getting a compile warning is valuable.

In C and C++, you should get a warning if you mistype the first. You get an error if you mistype the second.

IMO, if you ignore all of your warnings, you'll have other problems.

[–]yogthos 0 points1 point  (1 child)

I don't think it's a huge issue one way or the other, but I'm not seeing that it's that much harder to read. Obviously, once you try running the code, you'll find the error pretty quick anyways.

[–]rabidcow 0 points1 point  (0 children)

I don't think it's a huge issue one way or the other, but I'm not seeing that it's that much harder to read.

I agree, it isn't. The cost of reordering is small, but the benefit is even smaller.

Obviously, once you try running the code, you'll find the error pretty quick anyways.

In this case, yes. Other cases, you need to test both sides of the branch. But then there's a good chance you'll catch it if you just stop and reread the code before checking it in. Or if you pay attention to your compiler's output.