1.7.6 Object Parameter Types in UML Class Diagrams

A Class Diagram Shows Method Inputs

A UML class diagram lists a method's parameters in its method compartment. Each parameter has a name and a type.

Game class RecordTurn method takes a Player parameter.
Method signature in a class diagram
  • New
  • Changed
  • Removed
An Object Parameter Uses Its Class Name

A Game method that accepts a Player has this UML signature:

+ RecordTurn(participant: Player): void

`participant` is the parameter name. `Player` is the parameter type. The Game's method can receive a reference to a Player object.

C# Orders the Words Differently

The same input appears in C# as:

public void RecordTurn(Player participant)

C# places the type before the name. UML uses `name: Type`. Both descriptions say what input the method accepts.

Game class RenamePlayer method takes Player and string parameters.
Comparing UML signatures
  • New
  • Changed
  • Removed
The Diagram Describes a Class, Not a Specific Call

The class diagram says that Game can receive a Player. It does not identify whether Jordan's Player or Casey's Player will be passed on a particular call.

Several Inputs Appear in One Parameter List

`+ RenamePlayer(selected: Player, newName: string): void` describes two inputs: a Player reference and text. Each has its own name and type.