1.4.8 Representing Parameters in Sequence Diagrams

Representing Parameters in Sequence Diagrams

A sequence diagram shows which player receives a jersey-setting call and which value travels with that call.

Read the Code Before Drawing

The call is inside an existing Controller method. The variable player1 refers to a Player with SetJerseyNumber(int number), which stores number in its jerseyNumber field and returns void.

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

Source to translate
player1.SetJerseyNumber(7);
Rewrite the Meaning in Ordinary Words
Pseudocode for the same behavior
The controller calls SetJerseyNumber on player1
The call carries the integer argument 7
player1 stores that value in its jersey field
The operation 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 a sequence diagram in Violet. Place participant lifelines headed controller : Controller and player1 : Player. Both objects already exist.
  2. Place an activation bar on the controller for the calling work and an activation on player1 for handling the request.
  3. Draw a solid call from the controller activation to player1's activation. Label it SetJerseyNumber(7), preserving the actual argument in parentheses.
  4. End player1's activation when the method completes. If showing the dashed completion pictured below, label it completed (void); it returns control, not an integer result.
  5. Save and check that the message targets player1 and contains 7, rather than the formal declaration number : int.
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 calls SetJerseyNumber with argument 7 on player1; control returns without a value.
A concrete integer argument crosses to the receiver
  • New
  • Changed
  • Removed
Trace One Interaction from Top to Bottom

After the call, player1's jersey field is 7 under this method contract. The arrow itself shows the request and input, not an object snapshot.

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