3 ms·
That's not how reading works. You don't parse every character like a computer does. You look at the starting letter (maybe the ending one too) and then recogniz
by Mirioron 6y ago
That's not how reading works. You don't parse every character like a computer does. You look at the starting letter (maybe the ending one too) and then recognize the shape of the word used. There isn't too much difference in reading a long or short variable name as long as there aren't variable names that are too similar to one another.
- magoghm 6y agoActually what you need to recognize are expressions, and expressions with short variable names are much easier to recognize. For example, if I write: theDependentVariable = theCoefficient * theIndependentVariable + theIntercept it is much harder to recognize than if I write: y = a*x + b So, longer variable names might be "autodocumenting" but they also make code harder to read.
- erik_seaberg 6y agoYeah, letters don’t have much of a cost, but extra words do, which is why people complain so much about needing to plow through SimpleBeanFactoryAwareAspectInstanceFactories.
- cgriswald 6y agoI think you're offering a very particular case with a well-known idiomatic presentation and trying to apply it to the general case. In this case a, b, x, and y are both letters and good variable names for their purpose because of their long, familiar use in mathematics. But calling your main GUI window "m", your data "d", and your server connection object "b" doesn't make for readable code.
- souprock 6y agoYes, "as long as there aren't variable names that are too similar to one another"... It isn't safe to trust that to be true. That way lies bugs, including security holes. You have to carefully check the names. EthAccHdlrSubsMacPhysRegWrite and EthAccHdlrSubsMacPhyRegWrite Shorter is better, within reason.