Often when the syntax of the language requires me to name a variable that is never used, I'll name it
In my mind, this reduces clutter and lets me focus on the meaningful variables in the code. I find it to be unobtrusive so that it produces an "out of sight, out of mind" effect.
A common example of where I do this is naming subqueries in SQL.
SELECT * FROM ( SELECT * FROM TableA JOIN TableB ON TableA.ColumnB = TableB.ColumnB WHERE [ColumnA] > 10 ) _ --This name is required, but never used here ORDER BY ColumnC
Another example is a loop variable that isn't used.
array = [ for _ in range(n)] # Defines a list of n empty lists in Python
I use this technique very sparingly, only when I feel that a descriptive name adds nothing to the code, and in some sense takes away from it by adding more names to remember. In some ways I view it as similar to the
var keyword in C#, which I also use sparingly.
My coworkers disagree. They say that even having a single (alphabetic) character name is better than
Am I wrong? Is it bad practice to do this?