Hacker News new | ask | show | jobs
by akerl_ 1274 days ago
Do you type your variable names using vim or emacs?

“When should you use single letter var names” feels like one of those style/preference calls that doesn’t ever have solid rules, other than “if you’re working on a collaborative project, pick a rule and enforce it, even if it’s not perfect”

1 comments

I use vim exclusively but my names are still descriptive. To give an example from a file I have open right now:

    list($maxTrophies, $positions, $winStreak, $lossStreak, $lastfetch) = $result->fetch_row();
(This is my own hobby code on a solo project; not for an employer where I would be more careful to make it clear for others.)

Some are context-specific, like $positions being an array of how often you finished in which position (e.g.: [1,2,3]=[1 finish in 1st position, 2 finishes in 2nd position, 3 finishes as DNF]). Not all names will make sense if you're not familiar with the context, but given how often it's used, I think that's better than having to use onlineRaceFinishPositionArray. Maybe I could have used finishPositions, though. Not sure, it wasn't a choice I thought about very long, but I definitely am not using "p" as a "name".

For long names there is Ctrl+n, for example maxtr<Ctrl+n> will autocomplete to maxTrophies. Or for another example, "goldTime_ms": there isn't anything else starting with 'gold' than the gold medal time, and the underscore is annoying to type so this is nice to autocomplete.