I just had a discussion with a colleague where we disagreed about which of the following snippets was simpler:
public boolean foo(int x, int y) {
if (x < 0)
return false;
if (y < 0)
return false;
// more stuff below
}
OR
public boolean foo(int x, int y) {
if (x < 0 || y < 0)
return false;
// more stuff below
}
It is obvious which is shorter; it is also obvious that their cyclomatic complexity is identical (so for that definition of "simple", of course, they are the same).
What is your feeling, and why? Which is more readable; which is easier to debug?