Choose language

Forgot your password?

Need a Spoofbox account? Create one for FREE!

No subscription or hidden extras

Login


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.


Brian Goetz


#java #programming #design



Quote by Brian Goetz

Read through all quotes from Brian Goetz



About Brian Goetz





Did you know about Brian Goetz?

back to top