Here is a post where I want to share my knowledge on the immutable objects. Immutable refers to items that do not change. I just remember Hendry David's words when he says "Things do not change ; We change." . I believe these works refer s to immutable objects more perfect any other technical definition.
There are several types of immutability , lets talk about them here.
Write-Once immutability :
Constants are compile-time immutable types. These are objects whose values are set during the compile time and latter cannot be changed.
Readonly modifier ensures that the value of the object is set during the runtime and the values never changes.
Dormant Immutability:
Probably I have not coined a nice name for this type of immutability however what I would say is to there could be object which are persisted at some point and when they have to come back to life they are desterilized. In the world of BizTalk this is called hydration and dehydration. In such scenarios the object becomes immutable when it becomes dormant and becomes mutable when its desterilized.
Selective Immutability :
There could be scenarios where an object can be changed only under certain conditions or constraints such objects can be called as selectively immutable.
These are just few kinds which comes to my mind at this point. If someone finds other types feel free to post your comments and take the discussion forward.
Catch you soon …..
0 comments:
Post a Comment