Notes+10.4

We talked about OrderedCollection... it is a generalization of both Queue and Stack, a work-horse data structure which is often easier to use than an Array. The problem write-up in Moodle should give you a good idea of how to build one from elementary data.

Abstraction: focusing on the essentials of an issue, avoiding the details of a particular implementation. Example: the business of growing hair can be thought of generically. Various mammals grow hair in slightly different ways.

Example: we can think about taking a derivative of a function without even specifying the function. The derivative tells the slope of the function at most points (not at sharp corners).

Fence-post error If you want to build a fence 100 meters long, and you need a post at least every 10 meters or the wire sags too much, the answer is NOT 100/10 = 10. That counts the gaps. There's got to be a post on each end, so you need 11 posts. This kind of error happens. C's zero-indexing seems to exacerbate the problem. Your lab-mates might make this kind of error.

When testing at a threshold, test > or < instead of =. Example: thermostat. If the temperature = 65 Fahrenheit, turn on the furnace. OK, so the first time a kid leaves the door open and a mass of cold air comes in, the temp might drop to 63 without ever reading 65. Instead, use If the temperature <= 65 F, turn on the furnace.

NB: in class, Rik sometimes asks easy questions for review. Don't be afraid to guess the obvious.

Please excuse Rik's lack of energy today: I mentioned the stress in our family.