20

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?

13
  • 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". Feb 8, 2013 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. Feb 8, 2013 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.
    – Dan Blows
    Feb 8, 2013 at 16:39
  • 3
    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. Feb 8, 2013 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. Feb 8, 2013 at 16:57

1 Answer 1

27

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.

1
  • 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.
    – user40980
    Feb 8, 2013 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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