Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

methodName_whenInputDoesNotParseToValidRegexThrowException

They did a study and it isn't hard to read camelCase. https://ieeexplore.ieee.org/document/5090039



This study only compared camelCase to snake_case and what the results are mixed, depends on what you call "hard to read". They only seem to have tested finding identifiers from a word cloud, and it did take more time to read camelCase identifiers (although they were also resulted in more accuracy).

It's important to note that the researchers only tested short phrases with 2 and 3 words. "getNextPath" is a different beast compared to "methodName_whenInputDoesNotParseToValidRegexThrowException".

On the other hand, there is a good body of research that generally shows that proper sentences (not just 2-3 words) without spaces are harder to read, at least for English speakers[1]. Early medieval Latin manuscripts did not use space between words[2]. The fact that spaces were seen as an improvement when they were introduced, is probably telling.

[1] https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&q=unsp...

[2] Roman-era inscriptions did use an interpunct (a small middle dot) to separate words, but this practice fell out of fashion in Late Antiquity and Early Middle Ages and I'm not sure if it was ever the norm in handwriting.


From experience CI test reports are vastly more comprehensible at a glance.

That study compared camel case to underscore spaces. Well underscore space is still not as readable as methods with spaces and dashes.


Sure, but I like writing the other more. It's entirely a style thing and you're not required to do it :) it's also basically only ever seen in tests :)


I mean, it's harder to read compared to normal text with spaces and punctuation.


That doesn’t seem to be the case based on the study. And normal for one thing, such as paragraphs of prose, might not translate to another thing, such as a sequence of words in a line of code.


That’s just one study, and I’d argue we should write books in camel case to make them more compact if there’s truly no difference.


> That doesn’t seem to be the case based on the study.

The study does not say that camelCase is unequivocally as easy, or easier, to read.

Selecting the correct identifier from a list of 2-3 words (expandAliasTable, expandAliasTitle, etc.) is a wholly different exercise.


Ah thank you for actually reading the referenced study




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: