3 ms·
'a' and 'i' are perfect for indexes or range traversals. Yes, myVar is bad. You can always read the context and see 'for value in list_of_values' or understand
by raverbashing 7y ago
'a' and 'i' are perfect for indexes or range traversals. Yes, myVar is bad.
You can always read the context and see 'for value in list_of_values' or understand what's it that you're working with right now.
Yes, be more explicit on the tricky parts, but sometimes i = i+1 is just fine.
- onion2k 7y ago'a' and 'i' are perfect for indexes Except they're not as good as 'index', which is obvious and provides some meaning, so why accept single character name? I have an eslint rule that blocks single character var names on my projects. It makes my team develop good habits, and no one has ever complained about it. Our code is very readable.
- raverbashing 7y ago> so why accept single character name? Because readability suffers with repeated long variable names There's a reason why math uses i,j,k and x,y,z and it's not to be petty.
- onion2k 7y agoThere's also a reason why a lot of people find equations incredibly hard to parse.
- Nevermark 7y agoThis is a nice semi-random deeply nested spot to observe how the topic of naming is so cognitively attractive. Even in the meta-sense it is being discussed here. There is something about naming that we like thinking about, and fine tune our thoughts on, more than a simple need for legibility. There is a sense of ownership in picking a name.
- de_watcher 7y agoAre you awful or just trolling? I've said that naming is very important, but I didnt't suggest that people should choose a longer word when two are equivalent. A real way to give 'more meaning' to the index is to indicate to which collection it belongs.