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

  • eluvatar
    link
    fedilink
    arrow-up
    1
    ·
    9 hours ago

    I was trying to think of a good real world example, but couldn’t think of anything. But if you were to think of it as Google docs. You could just copy every doc to change it, but if you’ve shared it with people then you will have to share it again. It also takes up a whole lot more space to do that, sure you could delete those old ones but that takes some work too.