Title: Stepwise Refinement
1Stepwise Refinement
- A program design strategy where a solution is
first described in terms of high level functions,
then each function is broken down into details
that are refined in successive steps until the
whole program is fully defined. - This PPT originated with Dr. Roland Untch.
2Harvest Task
3- Stepwise Refinement helps us write good
programs - Stepwise Refinement tells us not to delve into
details too quickly, but to gradually solve the
problem by breaking it into smaller sub-problems. - Each sub-problem is then solved (also using
stepwise refinement.) - Eventually our solutions are expressed in
detailed terms.
4Harvest Task Design 1
5Other Harvest Task Designs
6 Which harvest design is better? Can you think
of other designs?
7 We might solve the harvest problem as
follows include ltkarel.hgt int main()
TurnOn() Move() HarvestARow()
TurnLeft() Move() TurnLeft()
HarvestARow() TurnRight() Move()
TurnRight() HarvestARow() // can you
finish the coding??? // more code goes here..
8What are the new commands that you used in your
design?? The command HarvestARow() is a new
command, so the next step is to write this
command. We might write the first new command
as void HarvestARow() PickBeeper()
Move() PickBeeper() Move()
PickBeeper() Move()
PickBeeper() Move()
PickBeeper()
9 What other new commands (to Karel) did you use?
We need to write those as well?
10Stepwise Refinement(another definition)
- The software design technique that aims to
describe functionality at a very high level, then
partition it repeatedly into more detailed levels
(one level at a time) until the detail is
sufficiently refined to express directly as code. - Also called top-down design.