Object Oriented Software Engineering   View all facts   Glossary   Help
subject > pattern > design pattern > immutable
Next design patternobserver    Updesign pattern    Previous design patterngeneral hierarchy   

immutable comparison table
Subject have solution have related patterns have context have forces have problem has definition is a subtopic of is a kind of is an instance of
design pattern zero or more related design patternsa contextone or more forcesa sentence or two explaining the main difficulty being tackledA pattern useful for the design of software6.1 - Introduction to Patternspattern 
immutable
  1. Ensure that the constructor of the immutable class is the only place where the values of instance variables are set or modified.
  2. If a method that would otherwise modify an instance variable must be present, then it has to return a new instance of the class.
Read-Only Interface pattern provides the same capability as immutable, except that certain privileged classes are allowed to make changes to instances.html>
  • The immutability must be enforced.
  • There must be no loopholes that would allow 'illegal' modification of an immutable object.
How do you create a class whose instances are immutable?A pattern in which the instances of a class cannot change state after creation6.10 - The Immutable Pattern design pattern

Next design patternobserver    Updesign pattern    Previous design patterngeneral hierarchy