|
|
|
|
|
by mortylen
953 days ago
|
|
I think the difference between a long function and many short functions that are not reusable is not big. A long function can be cluttered if it is really too long, and also many small helper functions can bring confusion to the code. The advantage of short functions can be their testing, or the division of work in the team. Anyway, if too long functions or too many one-call functions start to appear in the code, the code architecture should be reconsidered. |
|
Some languages have block scopes that can make this better; my position is against long functions in languages that lack block scopes or written by programmers that do not avail themselves of block scope.
I really struggle to see why anyone is not attracted to that form of abstraction: if local variable foo is computed in 10 lines using local variables bar, baz, and qux, and those 3 are not used for anything else, then clearly matters are improved in a 100-line function by replacing those 10 lines with
Authors of long functions are not embracing appropriate modularity, but that seems inexplicable, since modularity is the basis of the software revolution.