1.7.7 Representing Object Parameters in Sequence Diagrams

Representing Object Parameters in Sequence Diagrams

The controller asks a game to record Jordan's turn. The player is an argument, while the game is the receiver.

Read the Code Before Drawing

Inside an existing Controller method, game1 refers to Game and jordan to a Player with NumberOfTurns equal to 0. Game.RecordTurn(Player participant) increments that player's NumberOfTurns field directly.

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

Source to translate
game1.RecordTurn(jordan);
Rewrite the Meaning in Ordinary Words
Pseudocode for the same behavior
The controller calls RecordTurn on game1
The argument is the reference to existing jordan
The method parameter now reaches the same Jordan
Game increments Jordan's field directly
The call completes without returning a value

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 Lifelines and Messages
Build the Diagram in Violet
  1. Create lifelines controller : Controller, game1 : Game, and jordan : Player. All are existing objects.
  2. Draw a solid request from controller to game1 labeled RecordTurn(jordan). Activate game1 while it handles the request.
  3. Add a note spanning the game and player columns: participant refers to jordan; NumberOfTurns becomes 1. The note explains direct field access rather than another method call.
  4. End the game activation and show the optional dashed completed (void) control return to controller. Do not draw a creation message for Jordan.
  5. Save and identify receiver, argument, and changed field separately. The argument reference belongs on the request label, not as another new object.
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.

Controller sends RecordTurn with Jordan as argument to Game; Game updates Jordan directly and returns control.
A Player reference is supplied to a Game operation
  • New
  • Changed
  • Removed
Trace One Interaction from Top to Bottom

After the operation, Jordan's count is 1. The third lifeline identifies the argument's target, but no message arrow reaches it because the defined body makes no Player method call.

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