Tuesday, June 26, 2012

Different Minds VI (Clues)

A big clue came when one of my colleagues (another Chris), whom I know to be an exceptionally competent and intelligent man, said that although he literally hadn't noticed the noise, he also hated the overcrowded office because he was constantly distracted by people moving around in his peripheral vision.

I wondered why on earth that would be a problem. And he said that any visual distraction made it difficult to think. He looked at my computer screen and said "For instance, I couldn't get anything done with that messy arrangement of windows".

It hadn't occurred to me that my desktop was messy. I'd just opened various programs and moved the windows so that I could see them all.

So I asked him if he was disturbed by pictures hanging at odd angles, and he said that he couldn't think at all in a room where there was an odd hanging picture. WTF? I mean, if I noticed that a picture was at an angle, I'd fix it next time I was near the picture, but I'd be quite unlikely to notice unless it was about 20 degrees out, and even then I'd probably go through several cycles of forgetting about it and re-noticing before I got round to it.

Whereas to Chris, this was as annoying as music is to me. You can't think near it. It uses the bit of your brain that you want to use when you think.

At this point, I remembered an article I'd once read by Richard Feynman, describing how he'd taught himself to count time. With a bit of practice, he'd found that he could count at a nice even pace, and so could make accurate timings of things. But he'd noticed that there were some things he couldn't time like this, because he couldn't count while doing them.

So being Feynman, he made a list of all the things he could do, and all the things he couldn't do, and then he got colleagues to learn how to count evenly, and then got them to make lists of the things they could and couldn't do.

And to his amazement, the lists were not at all the same.

To cut a long story short, it turned out that some people were counting by saying the numbers to themselves, and some people were counting by looking at an imaginary clock and imagining it move. And that meant that different activities disrupted the process.

So I asked Chris what else he found interfering with his programming. And the list of things freaked me out completely.

One of them was the way the code was formatted.

Programming uses a lot of punctuation. For instance a piece of code might be formatted :


The punctuation lets the computer know where various bits of the program start and end. If you're talking to a human you might say 'Go and buy me 20 cigarettes and a mars bar', and it's obvious what that means, but computers are not terribly bright, and have trouble breaking the sentence up into its logical bits, so to help it 'parse' the sentence you have to say something like

Go; //and
Buy (me) { 
   20 * cigarettes ; 
   1 * mars bar ;
Come back;

This could be a real piece of code (meaning to do a thing 10 times):


But it's a bit dense for human eyes, so we tend to put extra spaces in to make it look better:

for( i = 0 ; i < 10 ; i++ ) {
     do ( thing ) ;

They don't change the meaning, they just make it nicer to look at.

And programmers fight holy wars over where to put the damned spaces.

Here's another popular style:

for( i=0; i<10; i++ ) {
      do( thing ); }

A lot of people seem to thing that this is terribly important. Most companies have a complicated document specifying exactly what the 'house style' is.

I have honestly never cared in the slightest. Even though I've never used the term 'special snowflake' about the people who do, it accurately sums up my attitude to anyone who'd get involved in an argument about where to put the damned spaces. If anyone tells me I'm doing it wrong, I usually let them reformat my code so that it suits them. I usually can't tell that they've done it afterwards, but it makes them happier, so what-ever...

But I've seen people get so angry about the issue that I thought they'd fight. And I've never known why.

The funny thing is, even though Chris could tell me exactly which bits of our codebase were well formatted and which weren't (In the same way that I can tell you which Cambridge pubs and cafes play music, which play music with words in it, and which tend to be quiet places suitable for thinking in), he didn't think that my stuff was badly formatted. So obviously even though I don't notice it, when I'm writing code, I have a consistent style I stick to. Except that I couldn't tell you what that style is. And I don't care about it.

No comments:

Post a Comment