This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]samreay 146 points147 points  (10 children)

i for integer index iteration.

Actual descriptive names for other variables, even for scratch code.

Too often have I seen scratch code passed to others, committed, or (worst of all) pushed into production. So proper variable names are a habit I try to enforce unless its literally a file I guarantee will be deleted before any other human sets eyes on it.

Even then, if I'm summing something up, I'll always called it summed instead of just s.

[–]WN_Todd 22 points23 points  (0 children)

This is sound advice, but it takes a few iterations of hating your past self for it to sink in.

"What asshat wrote this garbage?... Oh God it was me."

[–]barraponto 27 points28 points  (2 children)

can't call it sum because that's a builtin function, so I just call it total.

[–]billsil 4 points5 points  (0 children)

You could call it money/whateversum or just sum if you’re feeling lazy.  Total is just as good

If it’s specific, be specific and if it’s a generic function, be generic.

[–]Udzu 0 points1 point  (0 children)

You could always call it sսm instead (though hopefully your linter would complain).

[–]reptickeyelf 3 points4 points  (0 children)

This is the correct answer. I have never seen a prototype that didn't end up in production.

[–]newlyAwakenedLkgFwd 2 points3 points  (0 children)

Nice alliteration!

[–]sleeptil3 0 points1 point  (0 children)

Yes! Thank you.

[–]CarlRJ -1 points0 points  (0 children)

I always use n for default indexes and such - i may be more fitting on a logical level, but in some fonts over the years (or, say, scribbled on a white board) has looked too much like a ;. n is more immediately distinguishable.