If some object bar
holds a reference to a mutable object foo
and encapsulates some of its state in mutable aspects of foo
's state, that will allow code which can change those aspects of foo
to change the corresponding aspects of bar
's state without actually touching bar
or even knowing of its existence. Generally, this means that objects which encapsulate their own state using mutable objects must ensure that no references to those objects are exposed to any code which might unexpectedly mutate them. By contrast, if bar
holds a reference to an object moo
and only uses immutable aspects of moo
other than identity to encapsulate its state, then bar
can freely expose moo
to outside code without worrying about anything the outside code might do to it.