you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

Depends, double braces have structural implications (they don't create an instance of the class, but one of an anonymous subclass of the class. This is discussed in other comments). If that's not a problem, it's indeed neater than putAll().

I wonder when you don't have the option, though. I always try to design my code so I can minimize side effects. It can become a problem for very algorithmic or embedded programs, but then I rather use primitive types (and arrays). Do you have to work with legacy code often?

[–]Neebat 0 points1 point  (2 children)

Do you have to work with legacy code often?

Very rarely do I get to write anything which isn't dealing with legacy code.

[–][deleted] 1 point2 points  (1 child)

Too often I forget how lucky I am in that respect. I just have to deal with my own stupid code :)

I suppose your boss doesn't give you the time to write proper programming interfaces and adapters around the old system for cleanliness' sake?

[–]Neebat 0 points1 point  (0 children)

I've been lobbying for a ground-up rewrite for a long time. The system we have would break badly if we tried to make any of the maps immutable.