Sam Hume

Greenhorn
+ Follow
since Nov 07, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sam Hume

Since the camps are generally evenly divided... I think that what your nitpicker is suggesting is generally the best route.


No doubt. I followed the nitpicker's guidance assuming there's more wisdom to be found down that path. But this is a nitpick I wanted to explore a little, rather than simply complying and moving on.
16 years ago
A nitpick reads something along the lines of: Avoid using a not (!) and an else in the same statement...Test for == and swap your if and else blocks.

Now, I'm aware of this rule of thumb, but I've also heard that it's better to put the expected result first and the exception in the else block. So, in the case of checking for failed method I might do something like:



In this case the normal and expected result of my method is to return a non-null result and keep on truckin'.

So my question is: which is easier to read?
1) eliminate the not (!) and swap the if and else blocks
or
2) keep the not (!) and put the expected/normal case first (as I've shown in the example)

And, are there any cases where using not (!) and else together makes sense from a readability standpoint?

Cheers,
Sam
16 years ago
Congrats on the new addition. Enjoy the Servlets ride.
16 years ago
Phew, after several attempts have just ridden over the java-4b hill. Time to stretch the legs, and hop back in the saddle for the Times assignment.

Sam
17 years ago