36
The advantages of immutable objects in Java seem clear:
- consistent state
- automatic thread safety
- simplicity
You can favour immutability by using private final fields and constructor injection.
But, what are the downsides to favouring immutable objects in Java?
i.e.
- incompatibility with ORM or web presentation tools?
- Inflexible design?
- Implementation complexities?
Is it possible to design a large-scale system (deep object graph) that predominately uses immutable objects?