Outline for May 8, 2009
Reading: §9.1–9.3
- Overview of top-down design
- Sometimes called “stepwise refinement”
- Break problem into smaller pieces, plus the “glue”
to hold them together
- Do the glue first, with the smaller parts being stubs
- Do the stubs
- Step 1: the program, at a high level (see
rps-1.txt)
- Play rock, paper, scissors against the computer
- Define goal, being specific
- Define input
- Define high-level design
- Step 2: Data representation, smaller pieces, and main program (see
rps-2.txt)
- Define the routines as stubs
- Do main, directly from the design
- Step 3: First routine, who wins (see
rps-3.txt)
- Test it with the main (see
rps-prog1.py)
- Step 4: Second routine, computer picks (see
rps-4.txt)
- Be sure to print the result; useful later on, so a separate
routine
- Again, test it with main (see
rps-prog2.py)
- Step 5: Third routine, user picks (see
rps-5.txt)
- Check for errors on entry, and announce results
- Again, test it with main (see
rps-prog3.py)