3.3.5.1 What Is the Optimum Size for Functions?

Generally speaking, the source code for functions should be kept small as this aids in readability and debugging. It is much easier to describe and debug the operation of a function which performs a small number of tasks. Also smaller-sized functions typically have fewer side effects, which can be the source of coding errors. On the other hand, in the embedded programming world, a large number of small functions, and the calls necessary to execute them, may result in excessive memory and stack usage. Therefore a compromise is often necessary.

Function size can cause issues with memory paging, as addressed in 16.5 Function Size Limits. The smaller the functions, the easier it is for the linker to allocate them to memory without errors.