Many years of coding have brought me to believe and try to reach this kind of if conditional coding: (demonstrated in C, but it's relevant almost to any language)
if(a <= 0)
return false;
if(strlen(str) <= a)
return false;
if(str[a] == NULL)
return false;
return true;
Which i think is much more readable than the next coding sample, especially on a vast number of conditions:
if(a >0)
{
if(strlen(str) > a)
{
if(str[a] != NULL)
{
return true;
}
}
}
While the upper code is much more readable, on large conditions you might find yourself closing so many "}", and the last code i believe is compiled to a better performing code.
Which one do you think it is better to be used?
(the code in this examples is just for demonstrating don't take it literally)