Mark As Completed Discussion

Advantages of Immutability Objects:

  • Immutables are very useful in concurrent programming to ensure thread-safety (where an object is shared by multiple threads at a single time). You can freely share your immutable objects with various threads, without having to worry about any sort of inconsistency.

  • Immutables are very important in cases where we deal with key-value pairs which never change. For example, consider maps. We locate everything on maps using coordinates (longitude and latitudes) which always remain the same, making immutable objects as the best option here.

  • They are really useful in ATM machine-like systems where if a system failure occurs before the completion of the transaction, the user may face critical loss. With an immutable class, your account balance will only change once you have received the cash from the ATM. Otherwise, you may throw an error message and prevent losing that amount.