1 / 10

Stepwise Refinement

Stepwise 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.

wilton
Télécharger la présentation

Stepwise Refinement

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stepwise 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.

  2. Harvest 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.

  4. Harvest Task Design 1

  5. 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 Other 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 <karel.h> using namespace std; int main() { TurnOn(); Move(); HarvestARow(); TurnLeft(); Move(); TurnLeft(); HarvestARow(); TurnRight(); Move(); TurnRight(); HarvestARow(); // can you finish the coding??? // more code goes here….. }

  8. What 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?

  10. Stepwise 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.

More Related