4 ms·
Naming is a social problem, and there's a strong risk of correlation with hidden social variables in any empirical study, while any non-empirical study is suspe
by barrkel 10y ago
Naming is a social problem, and there's a strong risk of correlation with hidden social variables in any empirical study, while any non-empirical study is suspect because humans are what counts.
In particular the most likely explanation for correlation between bad names and bad code is unskilled or inexperienced programmers. This needs to be controlled for.
My personal observation is that well-factored code can use shorter identifiers because it deals with fewer concerns. Long identifiers frequently indicate muddy thinking that mixes concepts, where the identifiers are burdened with disambiguation.
Further, in languages with particularly verbose identifiers (Java especially), it can get hard to see the wood for the trees: the density of text obscures code and data flow in the program. There's a similar argument to be made about the tradeoff between symbolic operators and textual operators: the more frequently they're used in a domain, the better they're represented by a symbol. Symbols, of course, are especially short identifiers.
- metaobject 10y agoI also think that smaller scopes/function bodies help to reduce variable name length. When you write small functions that solve a single problem, the variable names tend to be very concise. This approach helps me try to keep my code under 80 columns, and I feel that it greatly improves the readability. Regarding the verbose identifiers, I recall the first time I started looking at Objective C (and NextStep I believe) while attempting to get into iPhone/iOS development. I couldn't believe what I was seeing. IIRC there were function names that were damn near 80 characters long. I played around with it and built some simple iphone apps, but I just couldn't take it.
- sh_tinh_hair 10y ago"In particular the most likely explanation for correlation between bad names and bad code is unskilled or inexperienced programmers..." Totally disagree with this assertion: Laziness and two fingered typing are to blame.
- barrkel 10y agoTwo fingered typing causes bugs directly? Or it causes bugs because it encourages short names? The article is about the relationship between names and code quality. Naming is one of the hardest things to get right, I often have to comment on it in code reviews. Long names are usually more lazy than concise ones. The other problem is naming things more specifically than necessary, obscuring genericity of functions.