4 ms·
Single letters for iteration values are a common convention in a number of languages. In the case of user/users, I'm likely to miss the distinction when scannin
by khedoros 10y ago
Single letters for iteration values are a common convention in a number of languages. In the case of user/users, I'm likely to miss the distinction when scanning the code.
If I've got a bunch of little lambdas, short loops (under 10 lines, perhaps), or list comprehensions, I'm not going to use longer names in them, because the context is clear and limited in scope.
If the variable's got to stick around longer (like throughout a function/method), it'll get a more descriptive name. As the scope grows, the variable loses the context that it came from, and it's more likely to need a longer name to make its meaning clear.
- nailer 10y agoIterating user for users is also a common idiom. Additionally making others having to look at the context to know what a u is, multiplied by the amount of loops, is somewhat inconsiderate.
- stouset 10y agoFFS, it's on the same line of code. The variable is live for a single expression. This is style wankery at its absolute worst.
- nailer 10y agoSure but most functions are longer, small functions can grow, and consistency is better. On a separate matter: you should read the HN guidelines.
- stouset 10y ago> most functions are longer Irrelevant. This function is painfully short. > small functions can grow It's a microlambda passed to a map function. 99% of these will never grow past a single expression. Hell, 95% of these will never even be modified. > consistency is better What, exactly, is this inconsistent with? > you should read the HN guidelines There's a difference between being uncivil and expressing frustration frankly.
- nailer 10y ago> This function is painfully short. Irrelevant. Other functions are longer. And needless human minification will undoubtedly creep in there too. > What, exactly, is this inconsistent with? Other functions. > expressing frustration frankly. Calling someone a wanker isn't exactly a pinnacle of expression.
- pklausler 10y ago> Calling someone a wanker isn't exactly a pinnacle of expression. No, it's not. But you shouldn't confuse your own identity with your coding style preferences, which were what the comment used "wankery" to describe.
- khedoros 10y agoI know that it's common. I use it in cases where there are more than a few lines of code, where the reader would have to maintain context. Wider context equates to a more specific variable name. > multiplied by the amount of loops, is somewhat inconsiderate. And using the more detailed variable name is misleading. It implies a longer scope, to me.