3 ms·
Short variable names make code more readable in some scenarios, not less. fooBarBazThings.each(t => t.DoThing()) for (int i = 0; i < len(things); i++) { //
by kinjba11 6y ago
Short variable names make code more readable in some scenarios, not less.
fooBarBazThings.each(t => t.DoThing())
for (int i = 0; i < len(things); i++) { // i used here }
Some local code patterns are seen so often you understand it in one go. Something like
fooBarBazThings.each(fooBarBazThing => fooBarBazThing.DoThing())
for (int thingIndex = 0; thingIndex < lengthOfThings; thingIndex += 1) { // thingIndex used here }
Just clutters things up.
- ornornor 6y agoI disagree. I always use descriptive variable names. I have no idea what ‘t’ is. ‘thing’ is 4 bytes more. Not the end of the world, but much more readable. Same for ‘i’ vs ‘index’.
- drran 6y agoModified obfuscator can make your code even more readable. It can simplify functions in addition to variables. Also, it improves job security, which is important in times of covid.
- twic 6y agoThis is a bit of a false dichotomy, because the names don't have to be that long. fooBarBazThings.each(thing => thing.DoThing()) It's more useful when the receiver of the method doesn't tell you as much, eg: getRecentPurchases().values().forEach(price -> priceStats.accept(price));