Empirical data on the effects of immutability?

后端 未结 9 538
长情又很酷
长情又很酷 2021-01-01 19:03

In class today, my professor was discussing how to structure a class. The course primarily uses Java and I have more Java experience than the teacher (he comes from a C++ b

9条回答
  •  攒了一身酷
    2021-01-01 19:38

    I would point to Item 15 in Effective Java. The value of immutability is in the design (and it isn't always appropriate - it is just a good first approximation) and design preferences are rarely argued from a statistical point of view, but we have seen mutable objects (Calendar, Date) that have gone really bad, and serious replacements (JodaTime, JSR-310) have opted for immutability.

提交回复
热议问题