Hi,
>- I know that the variable ³state" created at the beginning of the method
>is the same one I can access at the end.
For short methods, it's easy to see this, by reading the code. In my view
easier than using "final", which makes the code less readable.
For large methods,... well you should avoid large methods :-) But sure,
for large methods, using "final" is OK for me, if you have variables on
the outer level. But for example here:
for (final String id : newBlobIds) {
assertTrue(splitBlobStore.isMigrated(id));
}
it's very easy to see that "id" is not changed. Or here:
public String getPath() {
final StringBuilder path = new StringBuilder("/");
return Joiner.on('/').appendTo(path, nameQueue).toString();
}
Or here:
while (true) {
final int expectedByte = expected.read();
final int actualByte = actual.read();
assertEquals(expectedByte, actualByte);
if (expectedByte == -1) {
break;
}
}
>(I think it¹s some kind of code smell to reassign parameter anyway).
There is a Checkstyle feature to ensure parameters are not reassigned. I'm
fine using it, even if it means we need to change some code.
>That¹s why I vote for the (b).
Even thought I prefer (a), I can live with (b), but I would very much
prefer using "final" only very sparsely.
Regards,
Thomas