On 1/7/2014, 10:44 AM, Gervase Markham wrote:
It would be very interesting for someone to see if any of the references Mike Hoye gives explain _which_ types of change lead to loss of productivity. For example, it could be that brace style does, and line length does not.

I've been digging into the research style and formatting questions a bit, and this is what I have so far.

Short version:

- Indent with 4 spaces,
- use CamelCase,
- bracing style doesn't matter,
- consistency is The Most Important Thing.

Those are all consistently-replicated results. I don't have anything about line-length yet; I'm working on it.

The details:

On Spacing and indentation: Steve McConnell, in his book "Code Complete", says that "S ubjects scored 20 to 30 percent higher on a test of comprehension when programs had a two-to-four-spaces indentation scheme than they did when programs had no indentation at all. [...] The study concluded that two-to-four-space indentation was optimal. Interestingly, many subjects in the experiment felt that the six-space indentation was easier to use than the smaller indentations, even though their scores were lower. That’s probably because six space indentation looks pleasing. But regardless of how pretty it looks, six-space indentation turns out to be less readable. This is an example of a collision be tween aesthetic appeal and readability."

I've ordered a copy of his book, to figure out what the original source material actually says, but my understanding is that Python standardized on four-space indentation because of these results.

Brace style: McConnell suggests - citing the Soloway and Ehrlich paper I mentioned, and others, that the specific brace style hasn't been demonstrated to matter all that much, provided it is always used consistently. Inconsistent bracing (exactly like every other inconsistently-applied coding style...) is what sends your thought process off into a ditch.

On CamelCase v. underscore_delimited variable naming and comprehension: Bonita Sharif and Jonathan Maletic at Kent State have concluded that - with some caveats about novice programmers - there's not a big difference in comprehension and accuracy between the two. That paper is here:

http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf

However, a related paper available here - http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=5090039 - (don't have the full paper, sorry) concludes that among experienced programmers, CamelCase, not under_score, is measurably the right thing.

So, there you go.


- mhoye



_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to