Roles of Variables Home Page

Changes in the Role Set

Roles are cognitive concepts, i.e., in some cases different people may perceive the role of a variable differently. For teaching purposes, however, we need a "standard" set of roles that most people can find appropriate. The original set of roles (Sajaniemi; 2002) consisted of the following nine roles (green for all variables, blue for data structures):

Role (v. 1.0) Example
Fixed value maxStringLength
Stepper count
Most-recent holder inputData
Most-wanted holder maximum
Gatherer sum
Follower prev
One-way flag errorsOccurred
Temporary temp
Organizer sortArray

Later (Ben-Ari, Sajaniemi; 2004) a tenth role, transformation, was added to cover cases where a variable is obtained by some calculation from other variables (v. 1.1).

Surveys in three programming paradigms -- OO, procedural and functional -- (Sajaniemi, Ben-Ari, Byckling, Gerdt, Kulikova; submitted) revealed that data structures needed two more roles and that the role of transformation is actually a special case of temporary (or in other case of some other role). Thus the new set consists of 11 roles (green for all variables, blue for data structure use):

Role (v. 2.0) Example Informal definition
Fixed value maxStringLength A data item that does not get a new proper value after its initialization
Stepper count A data item stepping through a systematic, predictable succession of values
Most-recent holder inputData A data item holding the latest value encountered in going through a succession of unpredictable values, or simply the latest value obtained as input
Most-wanted holder maximum A data item holding the best or otherwise most appropriate value encountered so far
Gatherer sum A data item accumulating the effect of individual values
Follower prev A data item that gets its new value always from the old value of some other data item
One-way flag errorsOccurred A two-valued data item that cannot get its initial value once the value has been changed
Temporary temp A data item holding some value for a very short time only
Organizer sortArray A data structure storing elements that can be rearranged
Container processQueue A data structure storing elements that can be added and removed
Walker currNode A data item traversing in a data structure

(Table in Finnish).

The web pages in this site represent roles as of the version 2.0. Older versions of some pages can be found here.


Last updated: November 29, 2005

Jorma.Sajaniemi@UEF.Fi