Computer Science, asked by aanyakkumar3214, 9 months ago

An immutable data type is one that cannot change after being created. Give three resons to useimmutaledata

Answers

Answered by vedantshende6454
3

Answer:

Explanation:

1. No side effects

In PHP objects are passed by reference, so we should be enough careful for what we do and how we use our objects, like in this (silly) example. 2. No invalid object’s state

Thanks to Immutable objects, we’ll always be in a consistent state, no matter what. Or even if you forget to call a certain method, after a certain operation, you won’t be able to end up in a situation where your application is in an inconsistent state. Many times, we have bugs where properties of our objects are not in the right state. With Immutable Object this should never happen.

3. Failure atomicity

With the usage of Immutable objects failure atomicity will be a default property for your objects. Let’s see a basic example

Answered by Anonymous
0

Tuples are immutable i.e the value cannot be changed. So, Option D is correct.

Similar questions