TLDR Web Dev · ARTICLES & TUTORIALS
IMMUTABLE BY DEFAULT: HOW TO AVOID HIDDEN STATE BUGS IN OOP
Summary from the TLDR Web Dev newsletter
Immutable objects should be used by default in object-oriented programming to avoid hidden state bugs caused by unexpected data modifications. This post shows a DateTime example where a shared mutable object led to a difficult-to-trace bug. Immutability prevents such issues by making it so data cannot be changed after creation, whereas the performance overhead is minimal.