Warning: a guy at a library code meetup in Cleveland pointed out my variable names and it fixed my whole learning curve | Coding For Beginners - Talk Freely
Warning: a guy at a library code meetup in Cleveland pointed out my variable names and it fixed my whole learning curve
Last month I went to one of those free Saturday code meetups at the Cleveland library, mostly just to sit in the back and mess with my little Python project. I had a script that scraped prices and named everything stuff like a, b, x1, x2. A guy maybe twice my age leaned over, asked what my data was, and said "I can't read this and neither can you next week." He made me rename one variable out loud and the whole thing suddenly made sense. He called it "naming it like you're explaining it to a friend."
I went home and spent 20 minutes renaming stuff in my project and found 2 bugs just by reading it. Now before I run anything I ask myself if a name would make a stranger ask a question. It slowed me down at first but I'm not scrolling back up to remember what x3 means anymore.
Anyone got a rule for when a name is too long? Mine are getting kind of ridiculous now.