Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

Making changes and fixes to other people's code is never fun. It is especially not fun when naming conventions and basic programming principles like using getter/setter methods are not used. It gets worse when part of a naming convention was used to specify variable scope only to have someone come along and change this variable's scope and not update its name to match the convention. Then there is the issue of unused variables. Unfortunately the former set of issues is a little harder to deal with, but unused variables can be removed at zero cost and so are a quick win in terms of cleaning up bad code. The trick is configuring your IDE to let you do this easily.

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.


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.