It makes the code icky and hard to debug, and you can simply return new immutable objects for every state change.
EDIT: why not just create a new object and reassign variable to point to the new object
It makes the code icky and hard to debug, and you can simply return new immutable objects for every state change.
EDIT: why not just create a new object and reassign variable to point to the new object
There are times when immutable objects are absolutely the way to go from a data safety perspective. And there are other times when speed or practicality prevail.
Never become an extremist about any particular pattern. They’re all useful - to become a master you must learn when that is.