1.4.4 Representing Action Nodes in Activity Diagrams

Representing Action Nodes in Activity Diagrams

An action node describes work performed during one execution. For the Wildcats, recording a turn is work; Player is simply a type name.

Read the Code Before Drawing

This is the body of an existing RecordTurn method. The integer field numberOfTurns belongs to its Player receiver.

If the underlying C# feature is unfamiliar, use the lesson below while reading this example.

Source to translate
numberOfTurns = numberOfTurns + 1;
Rewrite the Meaning in Ordinary Words
Pseudocode for the same behavior
Read the receiver's current turn count
Add one to that count
Store the new count in the same field
Finish this one RecordTurn operation

Use these words to follow one execution before drawing it. Keep the same order and the same alternatives as the source; simplify the wording without adding work that the code does not perform.

Map the Source to Nodes and Arrows
Build the Diagram in Violet
  1. Create an activity diagram in Violet and place an unlabeled start node.
  2. Add one rounded action node labeled Increase numberOfTurns by 1. This label represents the assignment in the method body.
  3. Connect the start to that action, then connect the action to an unlabeled activity final.
  4. Check that there is no condition diamond or return arrow: this one update is neither a choice nor a loop.
  5. Save and trace the action with a starting count of 2, then with 0. It should store 3 and 1 respectively.
Compare the Completed Soccer Diagram

Compare this reference with the diagram you built in Violet. Layout may differ; the source meaning, labels, and relevant connections should agree.

Recording one turn increases the receiver's numberOfTurns field once, then finishes.
One method body action
  • New
  • Changed
  • Removed
Trace One Route at a Time

With a starting count of 2, the action stores 3. Reaching the final node completes this operation; it does not delete the player.

Verify the Drawing Against the Source
Predict and Check a Small Change