A Coding Exercise
Ok, yesterday I promised an exercise to help you practice breaking larger designs and problems into smaller components. This weekend I'd like you to choose a physical object that you interact with, and model it as a simple software program. The example I'm going to use is my banjo, but I encourage you to pick your own item and work in parallel to my examples as I go over them next week.
There are a few constraints:
The object that you choose should take some sort of input or interaction from the user, which results in some sort of output. Try to find something that takes a few different inputs. For instance, on the banjo I can model the tuning of each string, the position of my left-hand fingers on the frets, and the force that I use to pick each string with my right. That gives me outputs of pitch, loudness, and duration.
Don't worry about modeling in real units or real-world accuracy, at least not at first. Worry more about getting conceptual relationships right. I'm not measuring the force of my fingers in newtons or the volume in decibels. An arbitrary numeric scale is fine. Once you have a working model, if it's interesting to you to go for scientific accuracy, then go for it.
Finally, your program should NOT have a graphical interface. Ideally it's a command line program. Focus on how you represent the components' behaviors in code and data, not on how the user interacts with your program. Some options for getting input to your program could be reading from a text file or prompting the user at runtime. For the output, a simple text readout is fine.
Bonus points if you write tests for the program ;)
Questions? Just hit reply and ask. Otherwise, we'll talk again next week.