DEV Community

Discussion on: How to write IMMUTABLE code and never get stuck debugging again

Collapse
 
abdadabda profile image
abda dabda

An interesting read, though I still can't understand one thing.
Instead of modifying already existing objects, we decide to throw them away and create new ones. This is fine. How does it help us with avoiding bugs, or ease debugging? We still have to populate a new object, possibly with values coming from somewhere, possibly from previous objects. There still can be some nulls etc, we still can get errors, and we still can have a situation when a value was introduced deep in the execution tree. I know that I possibly have some misconception or I understand the topic poorly, so I would be glad if this could be elaborated :)