1.7.8 Object Return Types in UML Class Diagrams

Return Type Appears After the Method

A UML method signature places its return type after the closing parenthesis. When a method returns a Player reference, the return type is `Player`.

Game class GetCurrentPlayer method returns a Player.
Method signature in a class diagram
  • New
  • Changed
  • Removed
A Player Return Can Describe a Getter

A Game class may show:

+ GetCurrentPlayer(): Player

The colon and `Player` say that the caller receives a Player reference. The empty parentheses say that this method has no parameters.

C# States the Same Return Type

The C# method starts with:

public Player GetCurrentPlayer()

C# puts the return type before the method name; UML puts it after the parameter list. Both signatures describe the same return type.

Game class methods show both Player parameter and Player return types.
Comparing UML signatures
  • New
  • Changed
  • Removed
Return Type Does Not Explain Object Identity

A method that returns the Game's existing `CurrentPlayer` and a method that returns `new Player()` both have return type Player. The method body determines whether the returned object already existed.

void Means No Returned Value

A method such as `RecordTurn(participant: Player): void` takes a Player reference but returns no value. Its input type and return type answer different questions.