There are lots of people supporting the notion that nested conditionals are bad for readability and thus should be avoided, like, for example, here:
http://www.dreamincode.net/forums/topic ... operators/
http://codereview.stackexchange.com/que ... this-abuse
Example code of a nested conditional:
Code: Select all
tmp = (someLongCondition1 ? (someLongCondition2 ? method1returnValue : method2returnValue) : method3returnValue);
Code: Select all
tmp = (someLongCondition1 ? (someLongCondition2 ? method1returnValue : method2returnValue) : method3returnValue);
Compare that to the following:
Code: Select all
if (!someLongCondition1){ tmp = method3returnValue;}else if (someLongCondition2){ tmp = method1returnValue;}else{ tmp = method2returnValue;}
Reasonable explanations please, "don't care" does not count.
P.S. I would like to ask mods not to lock this topic just because you don't care about the subject. This is the off-topic section after all.
Also, would be nice if this thread could be turned into a poll.