Stepwise Refinement is the process of breaking down a programming problem into a series of steps. You start with a general set of steps to solve the problem, defining each in turn. Once you have defined each of the steps you then break the problem down into a series of smaller sub-steps. Once this is complete you keep on going until you have described the problem in such a level of detail that you can code a solution to the problem.
Stepwise refinement can be represented diagrammatically as such:
Advantages & Disadvantages
Advantages of step-wise refinement
- By breaking the problem down into steps it is easy to get good understanding of the scale of the problem. As a result less time and resources will be required to solve the problem.
- Many of the design decisions can be made during the stepwise refinement process, making it faster to make changes than after coding
- Large projects can be broken down and certain components issued to different developers.
- The overview makes the project easy to manage.
- Investigatory projects cannot always be developed from the top-design
- Stepwise refinement does not easily allow for projects to evolve during the development as a result of internal or external factors.
Activity : Going Food Shopping
Use Stepwise Refinement to break down the process of going food shopping into levels of detail until you would be able to write a ‘shopping algorithm’.