4 ms·
Because bugs per line increase when functions get longer than one screen fold. As well as reducing the conceptual length of your function, bundling up part of
by sideshowb 8y ago
Because bugs per line increase when functions get longer than one screen fold.
As well as reducing the conceptual length of your function, bundling up part of it in another function called only once makes a statement, possibly even some guarantees about which variables are and aren't modified by the sub function.
It may also decrease the number of variables used in your function and hence the risk of misusing one.