CS 1713 Introduction to Computer Science:
How to Draw Diagrams
- On the left side of the diagram, list all of the variables.
- Each variable is represented by a box labeled by its name.
- A variable box contains the current value of the variable.
- For variables of primitive type (int, double, char, boolean, etc):
- The value of the variable is put in the box.
- If the value of the variable changes,
put a single line through the old value and
insert the new value in the box.
- Make your boxes large enough to show all of the past values of the
variable.
- For variables which represent objects (including arrays):
- The box will contain a reference to the object.
- A reference is represented by an arrow with tail in the box and
head pointing to the object value.
- If the value of the variable changes,
put a few lines through the old arrow and
insert the new arrow whose tail is in the box and whose head
points to the object.
- Objects are listed on the right side.
- Each object is represented by a box containing its state.
- The state is represented as a list of variables, each with a name
and a box to hold its value.
- These variables are represented as before with a name and a box.
- For array objects, there is one variable for each element of the
array.
- Use the index of the array element in place of the variable name,
since array elements do not have names.
You can find some examples
here.