Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> remember how it was introduced

The problem is that many times I have not read the definition to remember. Debugger puts me into a context where I have to figure out what `p` stands for. I go up the call stack and now there's `s` to be deciphered. Worse is the reuse of `p` for person, product, part, etc. in different contexts.

Debugging is not the only problem. Code is read rarely linearly. Many times I browse different uses of a function, or see how a data structure is modified in different contexts. Looking up single letter variables is just a waste of time.



This is a decent reason, but your original comment is dangerously close to a completely strawman argument of "the argument of the func AverageAge(people []Person) should be called peopleToCalculateTheAverageOfTheirAges because what if I forget the method's name or its purpose while I am reading its text?"

Which, now that I think of it, kinda applies to your argument as well. Yeah, the debugger dropped you into the middle of a function you see for the first time in your life. No matter how you dice it or slice it, this means you'll have to study this function; I personally find that going to the function's beginning and skimming it until the breakpoint is the most reliable (and therefore, on average, fastest) method.


I don't deny the trade-off between variable name length and other factors. But, between 1 and 38, I doubt that the optimal length is at 1. Adding 5 more letters doesn't take anything away, IMHO, while increasing comprehensibility significantly.


> Debugger puts me into a context where I have to figure out what `p` stands for.

`p` stands for "the process in question".

I like to think of single-character vars as idea or topic headers that track the single thing I'm currently up to. I'm rarely working with more than one at a time, frequently it's the only variable, and there are contexts where I wouldn't use them at all.

IMHO if you're in a situation where `p` isn't obvious to you, "something has gone wrong".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: