Checking negative of a condition
Posted
by
oym
on Programmers
See other posts from Programmers
or by oym
Published on 2014-08-21T14:13:12Z
Indexed on
2014/08/21
16:27 UTC
Read the original article
Hit count: 189
coding-style
|terminology
What is the (slightly pejorative) term for checking the negative of a condition (rather than the positive which is often more readable):
e.g.
if(!someVar) {
return null;
} else {
return doSomethingInteresting();
}
instead of doing this (which is arguably more readable)
if(someVar) {
return doSomethingInteresting();
} else {
return null;
}
I vaguely remember there being a term for this; something in the same spirit as the term Yoda conditions.
© Programmers or respective owner