Roles of Variables Home Page

Roles of Data Entities

This document contains descriptions of roles of data entities as found in novice-level programs.

Note: Role lists suitable for novice use can be found in the page describing how roles can be utilized in teaching.

Roles in Different Programming Paradigms

The roles listed below apply to data entities in procedural, object-oriented, and functional programming. However, data entities having roles differ in these paradigms.

Procedural programming: Roles apply to variables, and parameters.

Object-oriented programming: Roles apply to variables, parameters, atttributes, and objects that encapsulate a single conceptual attribute.

Functional programming: Roles apply to the recursive behavior of parameters and return values

Notation Used in the Role List

Procedural examples are given in Pascal, object-oriented examples in Java. Procedural examples are whole programs because Pascal provides a possibility for short and at the same time complete example programs. Object-oriented examples assume the existence of other classes.

Notes that are in italics describe special cases and can be skipped on first reading. Technical definitions and properties provide more exact information about the roles, and they are not expected to be used in, e.g., teaching programming to novices.

Technical definitions may be needed in, e.g., role analysis. They are meant for human classifiers who are able to use their understanding of a program to capture the data flow through a data entity and identify main phases of this flow. For example, a one-way flag may be reset to its initial value at the beginning of the main loop (and changed within a nested loop) yielding the one-way behavior within the main loop even though the flag goes both ways during the entire program execution.

Properties are descriptions of actual use in novice-level programs or consequences of the technical definitions. They can be used in, e.g., devising pictorial representations for roles.

List of Roles

Roles can be grouped acording to the way they relate to data flow:

Role chart

Fixed value and organizer contain the same data throughout the program; only the order of data elements may be changed. Most-recent holder and stepper record data flow sources; either coming from outside or generated internally. The net effect of all items in a data flow is represented by a one-way flag, most-wanted holder, or gatherer; while a manipulation of a single element is recorded in a transformation, follower, or temporary. Finally, a data entity not covered by any of the previous roles is considered to have the role other.

The roles are described in the following order:

The role images are examples only. In actual use, they should be replaced by images better suiting the cultural backgrounds of users.


Icon for the role Fixed value (aka Constant)

A data entity whose value does not change after initialization.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity whose value does not change after initialization (e.g., an input value stored in a data entity that is not changed later) possibly done in several alternative assignment statements (e.g., a data entity that is set to true if the program is executed during a leap year, and false otherwise) and possibly corrected immediately after initialization (e.g., an input value that is replaced by its absolute value if it is negative).

Properties:

  • Impossible to change after initialization.

  • May have two distinct values during its lifetime.


Icon for the role Organizer

An array which is only used for rearranging its elements after initialization.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    An array which is only used for rearranging its elements after initialization (e.g., an array used for sorting input values).

Properties:

  • Individual elements cannot be changed but they can be moved around.


Icon for the role Stepper

A data entity stepping through a succession of values that can be predicted as soon as the succession starts.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity going through a succession of values depending on its own previous value and possibly on other steppers, stepper followers, and fixed values (e.g., a counter of input values, a data entity that doubles its value every time it is updated, a data entity that alternates between two values, or an index to an array that sweeps through the array using varying densities) even though the selection of possibly alternative update assignments may depend on other data entities (e.g., the search index in binary search).

Properties:

  • Most often the step between successive values is constant.

  • Future values can usually be predicted if past values are known.

  • Usually there is a direction for successive values; either upwards or downwards.

  • The validity of the stepper's value it is usually repeatedly tested against the same limit.


Icon for the role Most-recent holder

A data entity holding the latest value encountered in going through a succession of values.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity holding the latest value encountered in going through a succession of values (e.g., the latest input read, or a copy of an array element last referenced using a stepper) and possibly corrected immediately after obtaining a new value (e.g., to scale into internal data representation format).

Properties:

  • Successive values are obtained from some data succession but they have no fixed relationship.

  • Each value may consist of two distinct values: the original and the scaled/corrected.


Icon for the role Gatherer

A data entity accumulating the effect of individual values in going through a succession of values.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity accumulating the effect of individual values in going through a succession of values (e.g., a running total, or the total number of cards in hand when the player may draw several cards at a time).

Properties:

  • The new value is obtained by combining some new data with the previous value.


Icon for the role Most-wanted holder

A data entity holding the best value encountered so far in going through a succession of values.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity holding the best value encountered so far in going through a succession of values with no restriction on how to measure the goodness of a value (e.g., largest input seen so far, or an index to the smallest array element processed so far).

Properties:

  • The current value is better than any previous value.

  • Successive values are obtained from some data succession but new values are discarded if they are worse than any of those seen before.


Icon for the role One-way flag

A two-valued data entity that cannot get its initial value once its value has been changed.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A two-valued data entity that can be effectively changed only once (e.g., a data entity stating whether the end of input has been encountered) even though the new value may be re-assigned several times (e.g., a data entity initialized to false and set to true each time an error occurs during a long succession of operations).

Properties:

  • Only two possible values.

  • Impossible to regain the initial value once changed.


Icon for the role Transformation

A data entity that gets its new value always with the same calculation from value(s) of other data entity(s).

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity going through a succession of values depending on, but being different from, one or more most-recent holders, steppers or their followers, and possibly on fixed values (e.g., the kind or type of an input item, or a time given in hours, minutes and seconds converted to milliseconds).

Properties:

  • Tightly connected to another data entity(s) through some calculation.


Icon for the role Follower

A data entity that gets its values by following another data entity.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity which, apart from initialization, goes through a succession of values depending on the value of a single data entity that is updated immediately after being used for updating the follower, and possibly on fixed values (e.g., the previous pointer when going through a linked list, or the low index in a binary search).

Properties:

  • Tightly connected to another data entity; usually its previous value.


Icon for the role Temporary

A data entity holding some value for a very short time only.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    A data entity holding the value of some other data entity or input value for a very short time only (e.g., in a swap operation).

Properties:

  • Exists for short time periods only.

  • Tightly connected to the previous value of another data entity or input just read.


Icon for the role Other

Any other data entity.

Procedural example:

Object-oriented example:

Examples of use:

Notes:

Technical definition:

    All other data entities.

Properties:

  • No fixed properties.

  • Actual need is rare in novice-level programs.


Last updated: September 16, 2005

saja.fi@gmail.com