top | item 35961024

(no title)

fian | 2 years 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/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.ht...

discuss

order

winrid|2 years ago

I didn't say make everything immutable. I just mean that if you want an object to be mutable, you need to say so.