3 ms·
Experienced programmer should not be giving these kinds of vague general advice that really only apply to certain cases. Writing a sorting algorithm and a node.
by d--b 9y ago
Experienced programmer should not be giving these kinds of vague general advice that really only apply to certain cases. Writing a sorting algorithm and a node.js routing callback requires demands different styles. And if code already exists, just follow the same principles as what's already there. It's far more important to keep code formatting consistent than less indented...
I am not advocating for the opposite but having return statements in the middle of the code does have its drawbacks. In many instances it makes the code less easy to read.
For instance when I write:
If (x) {
Return y;
}
Return z;
I don't see that return y and return z are on the same conceptual level cause their indentation is different. The "else" is implicit, and so as a reader I have to make the effort of thinking "oh that part has already exited, so I'm in the case when 'not x'".
Anyways. All in all, just optimize your code for what makes sense and avoid general advice on code formatting.