I think sometimes it's better to think of the worst variable names, which I started to do after reading about the two worst variable names awhile back, which are (according to the post):
data
data2
All variables store data, and data2
is just lets us know you already used data
already.
I've definitely been guilty of at least the first, with variants like testdata
, rawdata
, theString
, etc.
On the other hand, I've also been known to make a simple for
loop into a novel because I wanted to make sure every variable was totally meaningful. And then I got to the next loop, nearly the same situation, and there I was with variable names like moreMeaningfulName
and counterOfBeans2
, not much better than data2
.
Point being is that it should be as meaningful as it needs to be. If you start using one letter iterators, you'll lose track, but in the end, they keep count and there will be another like it soon.
As far as function params, I've lately been trying to make it a habit to give the function a name that implies it's job and it's params, when possible, so the param names are already obvious. Like paymentSender(payment)
or addUserToSchedule(user, schedule)
. Not always an option, but usually if I can't think of a function name, I can think of the params, or I know the function name but not the params, etc.