6 ms·
Java has been around for a longish time. Around the early 2000's there was at least a perception that you should avoid creating too many objects as that carrie
by fian 3y ago
Java has been around for a longish time. Around the early 2000's there was at least a perception that you should avoid creating too many objects as that carried performance overhead for construction and garbage collection.
https://softwareengineering.stackexchange.com/questions/149563/should-we-avoid-object-creation-in-java https://softwareengineering.stackexchange.com/questions/1495...
Immutable objects often require you to construct a new object to store an updated value and garbage collect the now unused previous object. So a lot of early Java code was written with mutable objects to avoid performance issues.
The Java Bean spec was written in 1997:
https://blog.joda.org/2014/11/the-javabeans-specification.html https://blog.joda.org/2014/11/the-javabeans-specification.ht...
- winrid 3y agoI didn't say make everything immutable. I just mean that if you want an object to be mutable, you need to say so.