“Immutable objects are simple. They can only be in one state, which is carefully controlled by the constructor. One of the most difficult elements of program design is reasoning about the possible states of complex objects. Reasoning about the state of immutable objects, on the other hand, is trivial. Immutable objects are also safer. Passing a mutable object to untrusted code, or otherwise publishing it where untrusted code could find it, is dangerous — the untrusted code might modify its state, or, worse, retain a reference to it and modify its state later from another thread. On the other hand, immutable objects cannot be subverted in this manner by malicious or buggy code, so they are safe to share and publish freely without the need to make defensive copies.”
Quote by Brian Goetz
Work
Java Concurrency in Practice
Browse quotes and source details for this work. more
Author
You May Also Like
Source: Java Concurrency in Practice
Source: Java Concurrency in Practice
Source: Java Concurrency in Practice
Source: Java Concurrency in Practice
Source: Java Concurrency in Practice
“I built your ego, then shattered it when you revealed your true self.”
Source: Slammed
Source: From Mother to Daughter: Advice and Lessons for a Good Life
Source: One Minute to Midnight