14B. Avoiding the Swamp: Successive Refinement


What is successive refinement?

Successive refinement is a process for implementing a piece of software that greatly simplifies error localization.

If you try to write an entire piece of software before testing, then you will have a lot of mistakes, and you will have no idea where to look to localize each mistake. With a lot of mistakes, it is difficult even to extract a single mistake to work on.

Develop a refinement plan that breaks the implementation process into milestones, or stages. For example, if one job that your program needs to do is to read in some data from a file, then a simple milestone is a program that just reads the data and shows what it read.

Test the software after each stage. If there is a mistake, it is usually in the small part that you have just written. Localizing a mistake becomes easy, most of the time.

Of course, this only works if you test after each stage and you fix any mistakes that you found before moving on to the next stage.


Refinement barriers

Learning successive refinement is part of this course, and I am required to ensure that you learn things that are part of the course. Therefore, I must do something to ensure that students use successive refinement.

Each assignment has a refinement plan already prepared for you. You must follow it. Each step in the refinement plan is a refinement barrier, meaning the following.

If implementation of a particular stage A is always or almost always wrong, if stage B is later in the refinement plan than stage A, and if stage B depends on stage A, then any part of your code that is concerned solely with stage B does not count toward your grade.

For example, suppose the program needs to read some data. If the code to read the data is so wrong that it is unusable, then code for later stages that depend on the data will not count. Your grade will be as if you had not written them.

That gives you a strong motivation to ensure that each stage is correct before moving on to the next stage.

I am sure this sounds draconian. Unfortunately, in the past, many students have ignored all advice on how to avoid the swamp, and I am forced into this.