some useful tips for writing programs.
Here are some useful tips for writing programs:
Let’s read through those files in order to understand them. Moving forward, reading (and understanding!) someone else’s code, whether ours or some library’s, will often be the first step in solving a problem. That way, you can build upon the work of others and solve even more interesting problems yourself!
As always, when writing code, take baby steps, only implementing enough lines to make progress before testing (and, if need be, debugging) your code. Only once that first step is succesful (i.e., debugged!) should you take another. Plan each of your steps by writing pseudocode before code.
In the context of frequency specifically, taking baby steps might mean:
1. Only implement support initially for A0 through A8, no other notes. Ensure that frequency returns the expected values for those notes, as by running notes or using debug50 or eprintf. Compare your function’s output against your own calculations on paper or on a calculator.
2. Then add support for # and b but still only for A0 through A8 (i.e., A#0 through A#8 and Ab0 through Ab8).
3. Then add support for B. Then for C. Then beyond.