Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm wondering what's the reasoning behind Bootstrap's decision to change all camel case names into hyphenated names in v3.0. I searched on Google, and looked in a few books, but I can only find opinions one way or the other - no hard data.

Are there any studies that suggest camel case variable names are more readable than dashes, or is this just a matter of personal preference?

share|improve this question
1  
"Readability" may be better defined with wikipedia's metric listing, such as "speed of perception," "perceptibility at a distance," "perceptibility in peripheral vision," "visibility," "the reflex blink technique," "rate of work" (e.g., speed of reading), "eye movements," and "fatigue in reading". –  Jon Bringhurst Feb 8 '13 at 16:33
6  
@Blowski: Where on the page you linked does it discuss the change to hyphenated names? Bootstrap's library appears to be associated with HTML and CSS, where two-word attributes are always hyphenated by convention. They may just be doing it for consistency; all other things being equal, consistency wins. –  Robert Harvey Feb 8 '13 at 16:36
2  
@RobertHarvey the question was prompted by a discussion on Hacker News, which was itself prompted by the Bootstrap announcement. There was a lot of opinion on both sides, but no data - hence the question. –  Blowski Feb 8 '13 at 16:39
2  
Well, according to the Hacker News article (where presumably a principal of BootStrap was participating), BootStrap made the change because "in their gut, they felt it was right." They said they would have made the change earlier, except for backward compatibility concerns. –  Robert Harvey Feb 8 '13 at 16:55
3  
@RobertHarvey Further, look at the language that they're integrating with, CSS. CSS already uses hypens in nomenclature, it's almost a no brainer that they'd switch. So we're again back at your original idea for it, convention and pragmatism. –  Jeff Langemeier Feb 8 '13 at 16:57
show 8 more comments

1 Answer

up vote 23 down vote accepted

I'm stealing Robert's comment:

There are lots of things in software design and development that are driven, not by the result of formal studies, but by convention and pragmatism. That's why defacto standards exist; they arise out of everyday use, and many people discovering over time what works and what doesn't.

When it comes to choosing between camelCase and hyphenated names this is particularly true, as studies are inconclusive:

  • To camelCase or under_score - Dave Binkley, Marcia Davis, Dawn Lawrie, Christopher Morrell

    The study described in this paper shows that although those without training take longer to recognize identifiers in the camel case style, all subjects are more accurate when identifying a camel-cased identifier. In addition, subjects trained to use camel casing take less time to identify a camel-cased identifier than an underscore identifier.

    The next step is to consider higher-level tasks in more realistic settings. One task would investigate the impact of camel casing versus underscores when reading blocks of code. For example, subjects might be asked to search for a particular identifier. Another task would ask subjects to read natural language paragraphs modified to use camel casing or underscores. This would enable more direct comparisons with previous work done in psychology such as Epelboim et al.

  • An Eye Tracking Study on camelCase and under_score Identifier Styles - Bonita Sharif, Jonathan Maletic

    An eye-tracking study analyzing the effect of identifier style (camel-case and underscore) on accuracy, time, and visual effort is presented with respect to the task of recognizing a correct identifier, given a phrase. Visual effort is determined using six measures based on eye gaze data namely: fixation counts and durations. Although, no difference was found between identifier styles with respect to accuracy, results indicate a significant improvement in time and lower visual effort with the underscore style. The interaction of Experience with Style indicates that novices benefit twice as much with respect to time, with the underscore style. This implies that with experience or training, the performance difference between styles is reduced. These results add to the findings of Binkley et al.’s study. Future work includes conducting more eyetracking studies (with a larger subset of identifiers and larger subject sample), on reading source code consisting of both identifier styles, in the context of a specific task such as debugging. Another possible direction is to determine if there is an advantage for a programmer to change their current style to what is determined to be a better overall style.

    Note: The study referenced here as Binkley et al. is the first study I linked to.

share|improve this answer
2  
From the second study: "This implies that with experience or training, the performance difference between styles is reduced." to which one can answer "the one that is more readable is the one you use the most." -- Pick a convention and stick with it. –  MichaelT Feb 8 '13 at 19:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.