> you have to scan the entire function to get to know what variables it will use.
I don't use any IDE other than plain Emacs. But there is a search function, so the "scan"
that you mentioned is really by the editor program, not by myself. On the other hand, I don't
find it overly useful to know what variables a function will use. It is much more useful to
know what the function will do. Since I don't usually trust comments in code, this is a
difficult task by itself, and it is much easier if there is not a dozen of variables springing
up at the same point of code which are not used for a dozen of lines (and I have to repeatedly
use the editor's search function to know about it, and then keep forgetting it 5 seconds after
doing that). With C99/C++ style "declare variable on first use", I can tell easily which
assignment is an initialization and which is a modification to previously assigned value, the
latter I'll need to take much more care than the former.
> Having the code go too far to the right is a sign that you should probably break the
Of course. But nothing beats a function that have just one or two levels of indentations: it
doesn't overload myself mentally. Indentation is a necessary evil, it loads my mental
capability, but if you have a loop body you have to somehow differentiate it from the code
outside the loop, so it is still the best choice. Using braces also for just variable
declaration leads to quite a few more levels than what I usually want to see in the code,
especially those written by somebody else.
And "break the function" is not always practicible. Yes it is usually good, and when it is
good it is the best choice. But at the same time usually it is not good: at times it creates
a whole brunch of functions that has little meaning by itself and has to be called from a
particular context to be useful at all, and the context is in a form of very complex
preconditions involving its arguments, sometimes involving additional structures to hold the
results, the structures, of course, are of little meaning by themselves as well. A language
feature that provides an alternative when such "golden rule" is not practicible can only be a