Control Flow as Structured Code Annotations — 2. Dynamic Behavior

Control Flow as Structured Code Annotations is a sequence consisting of the following 2 notional machines:
1. Static Structure
2. Dynamic Behavior

Programming Language

imperative / any

Form

Representation

Attribution — Origin / Source

Collected by Peter Donaldson — Own practice, Peter Donaldson and Quintin Cutts

Conceptual Advantage

The notional machine is not an entirely separate representation from the code but acts as a secondary notation to add invisible aspects of the code execution.

Mapping

PLNM
... (all aspects from 1-Static Structure)
instruction execution add current step number to arrow leading in, then execute by adding to or looking up information in memory table, expression evaluator, or output areas
expression evaluation copy expression, substitute values, and evaluate it in expression evaluation area
variable declaration find first blank column in memory table and add name of variable in first row; value added underneath if initialised
variable assignment find variable in the memory table, strike through existing entry, and add entry to row below.
conditionals and loops evaluate control expression to 'True' or 'False', then follow relevant labelled control path to next instruction

Draws Attention To

Dynamic view of control flow (actual execution); evaluation of expressions; declaration, initialisation, access and assignment of variables.

Use When

Developing understanding of how basic programming constructs work.

Cost

Code needs carefully selected and formatted to enable annotation.

Details

Created by Peter Donaldson and Quintin Cutts / PLAN C project.

Check this research paper

Peter Donaldson and Quintin Cutts
Flexible Low-cost Activities to Develop Novice Code Comprehension Skills in Schools
WiPSCE '19

Two stages to TRACS trace

First, mark code with control flow paths and parts of the code containing expressions. Second, start at the top of the program and execute each line adding or looking up any necessary information from the memory table, expression evaluation or output areas.

Comments or Feedback?

Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.

For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".

Create an Issue on GitHub