r/programming • • Oct 06 '25

[deleted by user]

[removed]

155 Upvotes

218 comments sorted by

View all comments

Show parent comment

2

u/buerkle Oct 08 '25

It's been a long while since I read Effective Java, but I don't remember Bloch recommending modeling mutable singletons with enums. Not all singletons are mutable.

1

u/davidalayachew Oct 08 '25

It's been a long while since I read Effective Java, but I don't remember Bloch recommending modeling mutable singletons with enums. Not all singletons are mutable.

Well sure, not all singletons are mutable. But by definition of him saying "use enums for singletons", that includes mutable singletons too, hence my point.

I'm not trying to say all enums should be mutable. I am saying that mutation in an enum can be a good thing if used right.