Origin: | Grand 98 |
Reason: | An object's state should never change. |
Synopsis: | Set the state of an object at construction time. Do not define non-final variables or state-changing methods. |
Example: | An application deals with the positions of objects. Positions are not allowed to change. When an object moves, a new position for the object is constructed. |
Solution: | There are no specific classes. Constructors set all the state variables (the coordinates of a position). |
See also: | Singleton |