Different Types of Immutability

Different Types of Immutability 


Here are the specific types of immutability in programming:

Strict/True Immutability: The object or value cannot be changed at all after it is initialized. Examples include constants, strings, integers, and tuples in many languages.

Shallow Immutability: Only the immediate fields or references of an object are immutable, but the objects they reference can still be changed. A "read-only" field might point to a mutable object.

Deep/Strong Immutability: The entire object graph is immutable. All fields, and all objects referenced by those fields, are also immutable.

Copy-on-Write (Persistent Data Structures): While the data structure appears immutable to the user, any change triggers the creation of a new, updated copy. The original remains unchanged.

Compile-time Constants (Write-once): Fields that are assigned a value at compile-time and cannot be changed during runtime, such as const in C# or final in Java.



Comments

Popular posts from this blog

GHL Email Campaigns

Extras for New .NET Projects

JSON Web Tokens