Funny that when this subject comes up, almost everyone only talks about it making local variable declarations simpler.
What I think is a big advantage to var is that when you change the name of a class, it significantly reduces the number of files that have to be changed. Basically everything that doesn't instantiate the class, but only uses it, stays unchanged. Also it keeps down the number of imports you need, especially since Java prefers fully qualified imports instead of wildcard imports.
Oh yes, the merge conflicts. At work we have a large-ish codebase that gets merged into different products and also converted into different languages. One of the worst things regarding merge conflicts are renames.
33
u/FallingIdiot Mar 10 '16
Funny that when this subject comes up, almost everyone only talks about it making local variable declarations simpler.
What I think is a big advantage to
varis that when you change the name of a class, it significantly reduces the number of files that have to be changed. Basically everything that doesn't instantiate the class, but only uses it, stays unchanged. Also it keeps down the number of imports you need, especially since Java prefers fully qualified imports instead of wildcard imports.