WHILE loops and the analogy of the single stroke engine
Jerald D. Cole · ACM SIGCSE Bulletin · 1991
Researchers have found that loop constructs, such as the WHILE (top tested) and REPEAT-UNTIL (bottom tested) in modern programming languages are problematic for a significant number of novice programming students[5]. In theory, any bottom tested loop can be implemented as a top tested loop. Unfortunately, the converse of this is not true, leading to some of the confusions experienced by beginners. To circumvent this and other problems, Taylor[7] advocates postponing the introduction of the REPEAT-UNTIL. Instead, he discriminates between two fundamental types of WHILE loops, designated the SENTINEL WHILE and the COUNTER WHILE, which are sufficient for the implementation of any loop. A key element of Taylor's pedagogical approach is the introduction of these concepts in the context of analogies. This approach is utilized in the exposition that follows.