This post was brought to you by this PMD rule.
Transcription
Why do we have this stupid code analyzer rule enabled anyway? Nobody writes code like this…
After telling them the lore why it’s there:
You have seen such things before?
11 Times, as a matter of fact
It’s good practice to get in the habit of coding to only do the things you want/need to do rather than hoping the compiler does it for you.
This particular constructor call may be light, but there may be constructors that have a lot of overhead. Or you might be running alongside 1000 other processes who said the same thing and you start to see performance degradation.
These things add up if you’re doing them all over a 1 million line codebase, by which point it’s incredibly painful to claw back performance if you need it.
This seems like one of those cases where you don’t want to be waiting until benchmarking.
It makes the code simpler anyway.