On 1/7/2014, 3:46 PM, Mike Hoye wrote:


2 v. 4 spaces: more on that shortly.

An update on the research: Earlier, I said "four spaces" flat out, based on some conversations with researchers, but since then all the research I've been able to track down seems to cite the same paper. That paper says that two to four spaces of indentation results in better code comprehension than zero (obvs.) or 6+ spaces.

That paper is here: http://www.cs.umd.edu/~ben/papers/Miara1983Program.pdf

It also says that as long as it's consistent, block style doesn't matter, but that's not the most interesting thing here.

There are two things I've found while digging this stuff out that are really, really cool.

First of all: Perceived efficiency and real efficiency aren't the same thing at all. People asked to rate what codebase they found most pleasant and efficient to work with, consistently rating 6 or more spaces very higher than 2-4 spaces, but when you put those people in front of an eye tracker and a stopwatch, what they perceive as best isn't what actually works best.

It echoes this classic Ask Tog article from the 1989, about clicking icons with mouse v. keyboard shortcuts - People who think the keyboard is faster are measurably wrong, because their brains actually don't remember the time it takes to recall a key sequence, instead of clicking a button.

http://www.asktog.com/TOI/toi06KeyboardVMouse1.html

The other thing that's probably more important from a community engagement or developer-migration perspective is that real complexity and perceived complexity are also two entirely different things. A dirt-simple program with crappy formatting, or even just a new codebase in a format that's new to you, will be perceived as much more complex and _become much harder to understand_ than a genuinely complicated program with a clean, well-structured codebase.

Which is all to say that I think this is kind of important.

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

Reply via email to