An Educational Tool for Visualizing Students’ Program Tracing Processes CHIH-YUEH CHOU, PENG-FEI SUN Department of Computer Science and Engineering, Yuan Ze University, ChungLi, Taiwan Received 3 May 2010; accepted 1 August 2010 ABSTRACT: Program tracing is an important skill for programming learning, but novice programmers’ tracing abilities are poor. This study designs a system to enable students to exercise program tracing and make students’ program tracing processes visible to help teachers indicate students’ errors in tracing execution flow, variable values, or I/O display. © 2010 Wiley Periodicals, Inc. Comput Appl Eng Educ 21: 432–438, 2013; View this article online at wileyonlinelibrary.com/journal/cae; DOI 10.1002/cae.20488 Keywords: computer-assisted learning; programming learning; program tracing; computer science education
INTRODUCTION Learning to program is difficult because programming involves many complex cognitive tasks, such as program design, generation, and evaluation [1]. Program design includes planning, problem solving, and designing algorithms. Program generation involves applying programming language knowledge, such as syntax and semantics, to generate code for implementing the designed algorithms. Program evaluation requires comprehending, tracing, testing, and debugging the generated program. Thus, novice programmers must learn many cognitive tasks and may encounter many difficulties. This situation leads to many researches for assisting novice programmers in learning programming, such as investigating difficulties of novice programmers [2–5], designing programming courses and teaching methods [1], and developing computer-based programming learning environments [6,7]. Among cognitive tasks involved in programming, program comprehension has aroused much attention because it is vital to learn programming [8]. For example, students typically learn programming by reading and comprehending example programs. Program debugging also requires program comprehension to find out where the problem is [9]. However, program comprehension is a complex process whose goal is to build a mental representation of the program to connect the program code and the meaning of the code on the application domain [8]. Researchers have pointed out that program tracing, which is defined as “mental simulation of program execution [8],” is an important comprehension strategy [2,8]. In other words, program tracing means “taking the computer’s point of view” to determine precisely what a program does, including proceeding through the program step by step according to the primitives of the language and the rules of control flow and Correspondence to C.-Y. Chou (
[email protected]). © 2010 Wiley Periodicals, Inc.
432
interpreting “how each piece of code adds to the output or alters the value of a variable [2].” However, researchers have found many novice programmers’ program tracing skills to be poor when asked to predict program outcomes [10]. Novice programmers’ poor tracing skills are caused by lack of experience or lack of conceptual understanding of programming [8]. Researchers also found that some novice programmers do not even try to trace [2]. They also identified some reasons for the neglect of tracing: Students do not realize tracing as an important programming strategy and do not understand how the programming language works and lack tracing confidence. In addition, they suggested proper instruction, such as simply emphasizing the value of tracing strategy or teaching a mental computer model, might enable students to do better. Vainio and Sajaniemi [8] also suggested that “experience can be obtained by extensive training whereas understanding can be increased by instruction.” Teachers generally teach how a computer executes a program through presenting the program execution process step by step via blackboard, slide, debugger in programming integrated development environments, such as Microsoft Visual Studio or Eclipse, or some program execution visualization tools, such as ViLLE [11] or ETV [12]. Meanwhile, students learn the behavior of programs by observing how the teacher, debugger, or program execution visualization tool traces programs. However, students do not trace programs by themselves. Students may effortlessly follow the program tracing presentation, which is traced by teachers, debuggers, or tools, but fail to trace programs by themselves. Some teachers engaged students in practicing program tracing by predicting program outcome through paper-and-pen or mental simulation, but this method has two disadvantages. Firstly, students’ program outcome prediction only reveals the result of students’ problem tracing. The correct prediction does not imply that students did not make errors during program tracing. Students who accurately predict program outcome may have made errors during
EDUCATIONAL TOOL FOR VISUALIZING STUDENTS’ PROGRAM
program tracing. Secondly, it is not easy to recognize students’ tracing errors if the outcome is incorrectly predicted. The main reason is that students’ program tracing processes are invisible in program outcome prediction. Teachers need to recognize students’ errors from outcome prediction results, from incomplete doodle or annotation on paper [10] or through asking students to think aloud [13], or through the clinical mode of inquiring after students [2]. In sum, students lack environments and opportunities to practice program tracing and recognizing student’s tracing errors is not easy in program outcome prediction. This study develops a system to enable novice programmers to exercise program tracing through taking the computer’s point of view to simulate program execution. Furthermore, the system makes students’ program tracing processes visible and thus reveals students’ faults to account for why students’ outcome predictions are incorrect and allows teachers to indicate students’ errors in program tracing. The rest of the paper is organized as follows. The second section shows an example of the program tracing processes and possible errors. The third section presents the proposed system, named ProTracer. The fourth section describes an assessment of the system and its results. The last section makes concluding remarks.
A PROGRAM TRACING EXAMPLE While tracing a program, students need to track program execution flow step by step from a code line to another code line, and monitor value modification of variables and input/output (I/O) display after executing each code line. Figure 1 shows a C++ program code, which output outcome is “1:10, 2:9, 4:8, 5:7, 6:6” and the
Figure 1
433
An example of the C++ program code.
cursor is displayed at a new line. Table 1 lists the program tracing processes of the program, including the executed code in each step and variable value and I/O display after each code is executed. The program tracing processes comprise 29 steps. However, students’ faults in tracing execution flow, variable values, or I/O display lead to incorrect outcome prediction. Three control structures affect program execution flow: sequence, selection, and repetition structures [14]. Students with an incorrect understanding of meanings or the semantic of control structures may produce a wrong execution flow. For example, the program in the 12th step of Table 1 executes to the 5th line and the value of variable x is 3; the next step of execution flow should go to the 6th line and execute the continue instruction. Continue means that the execution flow
Table 1 Program Tracing of the Program in Figure 1 Step 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Executed code
Variables and values
I/O display
int x, y; for (x = 1, y = 10; x < 10; x++){ if (x = =7) if (x = =3) cout