1.3.4 Method Calls in Sequence Diagrams

Video: Interpreting Sequence Diagrams in This Course (7:05)
A Message Can Represent a Method Call

Suppose the C# source contains:

team1.DisplayName();

A sequence diagram can represent that call as a message sent to team1.

Conceptually:

caller ── DisplayName() ──> team1

The arrow shows the direction of the call.

The label names the method being called.

The Receiver Matters

For:

team1.DisplayName();

the receiver is:

team1

For:

player1.ShowStatus();

the receiver is:

player1

The sequence diagram should send the message to the object whose method executes.

Message Names Should Match the Code

If the method is:

DisplayName()

do not label the diagram message:

ShowTeam()

unless the source and model actually use that name.

Consistency helps you trace UML to code.

Order Matters

If code performs:

team1.ResetScore();
team1.DisplayName();

the first message belongs above the second message in the sequence diagram.

The diagram models execution order.

Current Calls Use Empty Parentheses

Method parameters are taught later.

At this boundary, a simple message such as:

DisplayName()

is enough to represent a parameterless method call.

A Sequence Diagram Is Not a Flowchart

The lifelines represent participants.

The messages represent communication between them.

Do not replace each method call with an activity-diagram action box.

Choose notation that matches the interaction question.