State - Immutable

> (Data|State|Operand) Management and Processing

1 - About

A state who is immutable cannot be changed.

An variable (object) is considered immutable if its state cannot change after it is constructed.

Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be:


3 - Rules

  • Don't provide "setter" methods — methods that modify fields or objects referred to by fields.
  • Make all fields final and private (ie have a local scope)

4 - Documentation / Reference