Roles of Variables Home Page
Sajaniemi J. (2002)
A New Approach to Variable Visualization: Roles as Visualization Objects
Proceedings of the Second Program Visualization Workshop (ed. M. Ben-Ari), Report DAIMI PB-567, Department of Computer Science, University of Aarhus, Denmark, June 2002, 75-83.
Introduction: Learning to write computer programs is a hard task for many students. One obvious reason is that programs deal with abstract entities formal looping constructs, pointers going through arrays etc. that have little in common with everyday issues. These entities concern either the programming language in general or the way programming language constructs are combined to produce meaningful combinations of actions in individual programs.
Visualizations may be used to make both programming language constructs and program constructs more comprehensible (Stasko et al., 1998). For the programmer, a programming language is just a tool to build the more important artefacts, programs, and hence visualization of higher-level program constructs is more important than visualization of language-level constructs. For example, Petre and Blackwell (1999) note that visualizations should not work in the programming language level because within-paradigm visualizations, i.e. those dealing with programming language constructs, are uninformative.
program doubles; var input, count, value: integer; begin repeat write('Enter count: '); readln(input) until input > 0; count := input; while count > 0 do begin write('Enter value: '); readln(value); writeln('Two times ', value, ' is ', 2*value); count := count - 1 end end.Figure 1: A short Pascal program.
As an example, consider the Pascal program in Figure 1. In this program the comparison "some_variable > 0" occurs twice - first to test whether the input value is valid and then to test whether there are still new values to be processed. In programming language terms, these two comparisons are equal: they both yield true if the value of the variable is greater than zero; otherwise they both yield false. In program terms, the meanings of these two comparisons are radically different: the first is a guard that looks at whatever the user has given as input and either accepts or rejects it, while the second is looking at a descending series of values and finds the moment when the series reaches its bottom. If these two tests are visualized equally, these visualizations do not provide students information about the program but about the programming language.
The dissimilarity of the tests cannot be observed by looking at the tests themselves or by looking at their locations within the syntactic constructs of the program. The distinctive issue is the nature of the values involved which requires a deeper analysis of the program. In the first test, the variable is an input value holder while in the second test the variable is a descending counter. In order to describe the true meaning of the tests, we must take into account this nature. In the following, we use the term role for the dynamic character of a variable embodied by the sequence of its successive values as related to other variables. The role characterizes the higher-level program information of variables.
Current visualization systems pay practically no attention to the roles of variables. Semi-automatic visualization systems (e.g., DYNALAB (Birch et al., 1995), Eliot (Lahtinen et al., 1998), Jeliot (Haajanen et al., 1997)) provide a set of ready-made representations for variables. These representations are based on text and simple geometric forms, and operate basically on the programming language level which does little to help students to understand how variables are used to build up meaningful constructs. Hand-crafted visualization systems (e.g., BALSA-II (Brown, 1988), LogoMedia (DiGiano et al., 1993), Pavane (Roman et al., 1992), POLKA (Stasko and Kraemer, 1993), TANGO (Stasko, 1990), Zeus (Brown, 1991)) give more freedom for variable visualization but they are used to demonstrate algorithms (e.g., various sorting methods) to intermediate students. Such visualizations are too difficult to novices trying to learn basic programming skills. In this paper we propose a mechanism to visualize variable roles to novice programmers and show how it is implemented in a prototype system we are currently developing.
The rest of this paper is organized as follows: Section 2 discusses the roles of variables and presents a set of roles with their characteristic behaviors. Section 3 is an overview of variable visualization in current systems. Section 4 describes how roles can be visualized, and discusses a new animation system that uses this approach. Finally, Section 5 contains the conclusions.
Back to the literature page
Last updated: August 1, 2005