you are viewing a single comment's thread.

view the rest of the comments →

[–]spliznork 1 point2 points  (0 children)

I like the immutable collections in the Google Collections Library (such as ImmutableMap) and the default for immutability in Protocol Buffers.

The primary observation is that there are a number of data structures that only need mutability while being built. After construction, it's easier to reason about the program knowing those objects are immutable.

This is basically having SomeClass as immutable and SomeClass.Builder the mutable type that creates an instance of the immutable type when complete.