Code Size of a Function
◀ Characteristics of a Good Function▶ Efficiency of a Function Amazon
s discussed in the previous chapter, small code size is generally better for a program. It is true for a function, too. A function with big code size can be hard to read and to understand.
When you find yourself having to write more lines of code than you anticipate you should consider breaking the function up into multiple functions.
However, when efficiency issues are taken into account, code size is no longer as important. As discussed several times, the recursive function to calculate a Fibonacci number is low in code size but is extremely inefficient. In this situation, the non-recursive version is much favored despite bigger code size.
Next let’s look at the efficiency of a function!
◀ Characteristics of a Good Function▶ Efficiency of a Function