4 ms·
>> The new API avoids this issue by ensuring that all its core classes are immutable and represent well-defined values. Is there any kind of talk of adding imm
by gldalmaso 13y ago
>> The new API avoids this issue by ensuring that all its core classes are immutable and represent well-defined values.
Is there any kind of talk of adding immutability to the core language? "final" keyword doesn't really cut it for objects and immutabililty by convention also is not easy to enforce on large teams.
- rlmw 13y agoThere has been a lot of discussion on this kind of thing. One of the proposals for value types is to have them be immutable. As to what to do in the meantime - I would suggest that you use either findbugs' immutability detection or Graham Allen's Mutability Detector: https://github.com/MutabilityDetector/MutabilityDetector https://github.com/MutabilityDetector/MutabilityDetector. Findbugs picks up an @Immutable annotation and checks whether this is the case, whilst Mutability Detector allows you to assert that classes are immutable as part of your unit tests. I appreciate its not as good as language support, but it is better than relying on an unchecked convention.