4 ms·
Fields of an object should typically not change. But yes, I had to make a field of a class immutable some time ago. There was a bug and I could not read the cod
by AtNightWeCode 5y ago
Fields of an object should typically not change. But yes, I had to make a field of a class immutable some time ago. There was a bug and I could not read the code to figure out were the object was changed. Still, caused by bad code. Same object sent around pretty much everywhere.
- slver 5y agoSo even you, the master of great code, wrote bad code. I guess immutability is worth something then.
- AtNightWeCode 5y agoI did not write the original solution...
- slver 5y agoSo you reckon we only need immutability if two or more people have to work on code. Ok.
- AtNightWeCode 5y agoYou are just too stupid. I hope you are not immutable.
- the_af 5y agoPrecisely: you did not write the original solution, which is where immutability shines. It's a code comprehension tool; it gives you guarantees about code you didn't write. That's a huge boon!
- AtNightWeCode 5y agoThere are no guarantees that it is the same object you get so it is pointless.
- slver 5y agoNo one uses immutables to make sure they “get the same object”. What does that even mean?