Roles of Variables Home Page

Gerdt P., Sajaniemi J. (2004)

An Approach to Automatic Detection of Variable Roles in Program Animation

Proceedings of the Third Program Visualization Workshop (ed. A. Korhonen), Research Report CS-RR-407, Department of Computer Science, University of Warwick, UK, 86-93.

Introduction: Many students have difficulties in learning to program computers. One reason that makes computer programming a difficult skill to learn is that programs deal with abstract entities, that are unrelated to everyday things. Visualization and animation is a way to make both programming language constructs and program constructs more comprehensible (Hundhausen and Stasko, 2002; Mulholland, 1998). 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. Hence students learning to program benefit more from visualization of higher-level program constructs than visualization of language-level constructs.

Sajaniemi (2002) has introduced the concept of the roles of variables which he obtained as a result of a search for a comprehensive, yet compact, set of characterizations of variables that can be used, e.g., for teaching programming and analyzing large-scale programs. A role characterizes the dynamic nature of a variable embodied by the sequence of its successive values as related to other variables and external events. A role is not a unique task in some specific program but a more general concept occurring in programs over and over again. Table 1 gives ten roles covering 99 % of variables in novice-level, procedural programs.

Roles can be utilized in program animation to provide automatic animation of concepts that are at a higher level than simple programming language concepts. In a classroom experiment (Sajaniemi and Kuittinen, in press), traditional teaching of elementary programming was compared with role-based teaching and animation. The results suggest that the introduction of roles provides students with a new conceptual framework that enables them to mentally process program information in a way similar to that of good code comprehenders. Moreover, the use of role-based animation seems to assist in the adoption of role knowledge and expert-like programming strategies.

In this paper, we will present the role concept and the role-based program animator PlanAni, and discuss possibilities to implement automatic role analysis that is needed in order to automatically animate programs provided by students.

Back to the literature page


Last updated: July 14, 2005

saja.fi@gmail.com