3 ms·
No, no, no, no. Did I mention no? I inherited a Javascript application that was maybe 1500 lines of code. Every function was 3-5 lines. Most were like this:
by SoftwareMaven 14y ago
No, no, no, no. Did I mention no? I inherited a Javascript application that was maybe 1500 lines of code. Every function was 3-5 lines. Most were like this:
process_foos = function(my_list) {
for (i=0; i<my_list.lengh; i++) {
process_foo(my_list[i]);
}
}
process_foo = function(foo) {
foo.some_method();
}
And foo.some_method (in another file) was similar. What it meant was it was impossible to get a view of what was going on in the system. It took months to accomplish an understanding that should have taken weeks.
I really think the original authors heard your advice and decided comprehension didn't matter, only function length.
Function should accomplish a task. Sometimes (very rarely) a task may be two hundred lines; usually, it is much shorter. Sometimes three lines, but often 15-20.