Outline for February 27, 2012
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
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
Define the routines as stubs
Do main, directly from the design
Step 3: First routine, who wins
Test it with the main [
rps-prog1.py
]
Step 4: Second routine, computer picks
Be sure to print the result; useful later on, so a separate routine
Again, test it with main [
rps-prog2.py
]
Step 5: Third routine, user picks
Check for errors on entry, and announce results
Again, test it with main [
rps-prog3.py
]
A PDF version is available here.
ECS 10, Basic Concepts of Computing
Winter Quarter 2012