3 ms·
As argued in, for instance, Hardcore Java[1], 'final' should definitely have been the default for variables in Java. My Eclipse 'on save' actions include making
by Confusion 17y ago
As argued in, for instance, Hardcore Java[1], 'final' should definitely have been the default for variables in Java. My Eclipse 'on save' actions include making every possible local variable, parameter and field final. If I'm reading the code and one of them is not final, I know it requires some extra attention.
[1] http://oreilly.com/catalog/9780596005689 http://oreilly.com/catalog/9780596005689
- Retric 17y agoWhat is wrong with loops?
- Confusion 17y ago:). I didn't mean it like that. I meant that when I'm reading code, I know to pay extra attention when something is not final. There will always be non-final variables around, for instance 'previousItem' to track the previous item through a loop. Added some words to the parent to clarify.
- bokchoi 17y agoPerhaps we should go even farther -- 'final' should be default on methods and classes as well. Derivation should only be allowed where explicitly granted by a programmer.