DEV Community

loading...

Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

Collapse
polomora profile image
Paul Moore

Interesting concepts about code readability, but I respfully agree.
I think that putting the else statement on its own line greatly improves the "line of sight" readability:
if( condition ) {
// statements
}
else {
// statements
}

Also, what about loops? They also break the same "line of sight" readability. What about switch statements? What about continue and break statements inside loops and switch statements? What about raising exceptions?

I think that helper functions also worsen the readability. For a programmer taking over or reviewing somebody else's code, helper functions definitely interupt the readability of the code.