12
A code review comment made me rethink variable names forever
I submitted my first real project last week and the reviewer left a note saying 'name this what it is, not what it does with it.' I had a variable called 'loopCounter' that was actually storing the user's age. I renamed everything to be plain and obvious, and now I can actually read my own code from Tuesday without a headache. Has anyone else gotten feedback that felt harsh at first but turned out to be the best advice?
1 comments
Log in to join the discussion
Log In1 Comment
wren2172d ago
Laughing at past me, because I once named a boolean 'notReady' and it was actually checking if the order was paid. Spent a whole afternoon flipping conditions trying to figure out why nothing worked. Your reviewer's note is basically the coding version of "say what you mean, mean what you say." I still catch myself naming things after my feelings about them, like 'finalFinalVersion3' for a config file. Honestly, plain names feel boring, but boring saves your sanity at 2am.
6