As I am currently engaged on the operations side of the project I'm working on, coding is but a fraction of the work I do. I don't write code for new functionality, I also don't get the time to refactor or improve existing code, I can only change code when we find an actual bug that affects operations of the live system. This really limits what you can do to fix bad code and to make it more maintainable. So this had me thinking, maybe there is something that can be done during those times that I actually have to update some code that will improve the overall quality, and turns out there is.
Unused variables are a pain and can be seriously misleading when trying to comprehend a piece of code. All reasonable IDEs can also tell you when a variable is not used. The trick is to make your IDE really YELL THIS FACT OUT TO YOU.
I use JDeveloper mostly, in its syntax highlighting options you can configure what an unused variable would appear as. I've decided to set the appearance to look like a big warning sign, bold red text on a yellow background. You just cannot miss it.
Something like this:
Every time I see one of those, it's a big warning sign to me, but also a big green light in terms of cleaning up the code.
I started to suggest that other people on the project do the same as well, in fact this should be standard for all IDEs, in my opinion.
-i