I understand the point about choosing the shortest name that clearly conveys the meaning of variable but scope seems irrelevant to me. Whether it's used in a single function or a class or a library, the name has to be clear no?

And using i & j as examples is cheating -- everyone who learns programming, knows i & j the loop variable context. Without that learnt context index will be a better choice.

With editors, it's not like you need to type the variable name fully. (look at me, someone who's not coded a long time debating with Mattn-san 🤦‍♀️)

Reply to this note

Please Login to reply.

Discussion

I understand what you says. :)

Using long variable names in a narrow scope can be noisy. Usually, as the scope gets narrower, what the variable points to should become more localised. For example, the relay URL list relayURLs is denoted relayURL in the loop, and the relay object resulting from that relayURL is named relay. However, if the range of occurrences of the variable is extremely small, it may be possible to avoid noise and use a single character. This is because the scope is narrow.

Thank you - I understand better now 🙏🙏

But with co-pilot and chatGPT, I suppose it will matter slightly less. The art of reading code to understand may be siphoned off to bots 😅