Going beyond the built-in functions, there are many functions that are called only once.
Let's say we have a structure like this:
typedef struct foo { char *foo; int bar; double foobar; } foo_t;
And we write something to initialize / highlight:
foo_t *foome(void) { foo_t *ret; ret = (foo_t *) malloc(sizeof(struct foo)); ... ... }
But why did we survive this whole problem when foome() is called only once, in main() ? Because we want the next person to deal with our program in order to be able to look at main() and immediately understand what we are trying to accomplish.
I would prefer to see code that has dozens of one-time functions, if that means that a complex algorithm is read like a book on one (or close) screen. I canβt say how much my head hurts when I have to scroll up and down a hundred lines trying to save my place.
This saves sanity and helps the environment, because now I do not need to print all 60 pages of your algorithm and place them on the table to read it :)
source share