Hacker News new | past | comments | ask | show | jobs | submit login

> Single Letter Variable Names

I saw @axegon_ talking about "Names From Other Languages" and calling it "worst thing that you could ever end up dealing with". But I tell you, a "Single Letter Name" master will turn your mind really quickly.

You open up the code, that's a file of over 2,000 lines, no comment. Everybody inside there were called `a`, `b`, `n`, `i`, `q`. Some functions were a little better, `handle`, `add`, `equal`, `DataClass`, `MainProcessHandler`, `Service`.

Yeah, I rewrite the whole thing because at least I can trust the stupidity of my own.




Weirdly enough, Go seems to actually promote short / single letter variables, depending on context: "The basic rule: the further from its declaration that a name is used, the more descriptive the name must be. For a method receiver, one or two letters is sufficient. Common variables such as loop indices and readers can be a single letter (i, r). More unusual things and global variables need more descriptive names."

https://github.com/golang/go/wiki/CodeReviewComments#variabl...




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

Search: