Skip to content

Comment on Ask HN: I prefer single letter variablesparent

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.