Wish list of functions

Sunday, May 10, 2020

A program contains multiple functions. We don't know all the functions that we will write for any program at the beginning. We have some idea, but the details are not clear. As we start to write our program, the need for new functions arise. So how do we keep track of functions that we need to work on? Use a wish list!

What does a function wish list look like?

It's pretty simple. It has three components, each one added to code as a comment:


Suppose we need a function that count the number of ‘a's in a string. What will a wish list entry of this function look like:

; how-many-a's?
; String -> Number
; count the number of a's in a string

Here we are saying our function name is how-many-a's?. Of course you want to meet the syntax requirements of naming a function for a particular language. In the signature comment, we say that this function consumes a string and produces a number. Lastly, we note the purpose of the function, in this case, count the number of occurrences of letter a in the input string.

That's it! You continue to add items to your wish list. Pick one item, work on it and take it off from the wish list. When nothing is left in the wish list, celebrate!

See HTDP for more details.