Thursday, 12 June 2014

Advantages Of Immutability

  1. Since Immutable objects won't change their state, so no concurrency over head required.
  2. They reduce errors: mutable objects are vulnerable to being changed when you don't expect it.
  3. They can be safely shared (i.e. multiple references to the same object) which can reduce memory consumption and improve cache utilisation.

Note : The only real disadvantage of immutable classes is that they require a separate object for each distinct value.

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment