Hacker News new | ask | show | jobs
by ReactiveJelly 1466 days ago
I read somewhere, "The length of a variable name should be proportional to the size of its scope".

Usually I don't have long loop bodies, so if the loop body fits in 24 lines, `i` is perfect for the index.

If I'm locking a mutex, doing something, and quickly unlocking it, `l` for the lock guard is fine.

But if it won't fit on screen, it needs a longer name.

And if there's something like a top-level `App` struct, I just call it `a` because its scope is really just `main`, even though its _lifetime_ may be the entire process.