4 ms·
Good article: things that are complex should have long names, things that are simple should have short names. Like the approach.
by petervandijck 16y ago
Good article: things that are complex should have long names, things that are simple should have short names. Like the approach.
- jacquesm 16y agoThings that have limited scope can usually get away with short names as well, even in a slightly more complicated context. But since the punch card went out of fashion a while ago and bits are nearly free (screen width otoh is not) it doesn't hurt to name all your variables descriptively. A global variable named 'i' is likely going to get you i trouble, then again, jQuery does most of it's magic using a single global that doesn't even have a name...
- joe_the_user 16y ago"But since the punch card went out of fashion a while ago and bits are nearly free (screen width otoh is not) it doesn't hurt to name all your variables descriptively." The bits are free but there's still a mental cost to reading them. I once rigorously used long-names for everything. But now, I'm working on an algorithm where the operations are what matter, short names actually help me grasp everything at once. As you say, these would be short local variable. Having i, j, k be the standard indexing variable can make some situations clearer.
- jacquesm 16y agoSure, that's fine, those are pretty close to universal. It would actually be less readable if you suddenly started to use long names for loop variables and such.