5.9 The inventory
Imagine that you’re trying to bake cookies. A smart cook will get all the ingredients (eggs, milk, butter, sugar, chocolate chips, etc.) out and put them on the counter before mixing anything together: that way you can see whether you have enough of everything. We’ll do something similar: list everything that’s available for you to use in defining the function, before starting to put things together. At this stage, that basically means the parameters (it will get more interesting later).
You should also recall from Chapter 4 that the parameter names that appear in the function header must exactly match those that appear in the function body — same spelling, same capitalization, etc. You may have no idea how the function body is going to work, but you can be pretty sure that the parameter names you put in the header will be used in it.
At this stage, I recommend writing the names of all the parameters, one on each line, commented out, in between the function header and the “...” where its body will eventually be. It’s often helpful to also write down, next to each parameter, what data type it is; this determines what you can reasonably do with it.
There may also be particular pieces of information that are always the same, regardless of the arguments passed into the function. For example, a function that is supposed to always draw in blue will presumably use the word "blue" at least once in its body. I generally ask students to write a skeleton, as above, and then insert the inventory information before the “...”.