Program State as Graph

Programming Language

object-oriented / Java

Form

Representation

Attribution — Origin / Source

Collected by Craig S. Miller — Interview, James Riely

Conceptual Advantage

Graphs make the relevant parts of program state explicit and support detailed explanations by instructor.

Mapping

PLNM
stack frame red rectangle, with method name and line number in left compartment, boxes for paremeters and local variables in right compartment
object purple rectangle, with class name in left compartment, boxes for instance variables in right compartment
array blue rectangle consisting of boxes for elements
static fields yellow rectangle, with class name in left compartment, boxes for class variables in right compartment
variable box inside a rectangle
reference value solid arrow pointing to a rectangle
primitive value value written inside a box
callee-caller relationship dashed red arrow from callee stack frame to caller stack frame

Draws Attention To

Program state, and especially variables and references.

Use When

To demonstrate how Java code advances through a computation, e.g., when working data structures.

Cost

Quick and easy to use, even when live-coding a solution

Details

James Riely developed and described a tool, in the form of a Java class, Trace.java, that produces graph representations of the Java program state in the form of GraphViz dot graphs.

Example Usage

He uses it in his CSC300 course at DePaul University. Here is one of the lecture videos, showing the traversal of linked lists.

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