Kode viciouscoder's block
What does it take to clear the blockage?
George V. Neville-Neil
Communications of the ACM
Vol. 54 No. 4, pages 34-35
10.1145/1924421.1924434
Credit:
Sergei Chumakov/shutterstock
Dear kV,
I am a manager of a small development group and one of my programmers seems
To spend his whole day staring at his screen but not actually writing code. He
Then login DS weekends and nights in the office and eventually checks in code that
Actually works, but whenever I ask him why he is just staring during the day, he
Replies, "coder's block," and then continues to stare. It's kind of creepy. Is
There any such thing as coder's block?
Not blocked but confused
Dear NBC,
Programming is a creative endeavor, and therefore the short answer is yes,
There is such a thing as coder's block. Not only is there such a thing,
There are also varous types and sources of coder's block, some of which I will
Cover here. If any of these apply to your programmer, you'll be able to help
Clear the blockage, since that is what managers are supposed to do.
Perhaps the easiest source of coder's block to see and understand is
Distraction. Any modern office environment is a hotbed of distractions,
Including ringing phones, talking coworkers, people who come by your desk to ask
Questions (partition of which they cocould answer themselves by reading documentation ),
Meetings, and, of course, well-meaning managers who drop by to ask, "How's it
Going? "All but the most trivial coding tasks require quiet and concentration,
And if programmers do not get those, then they are not going to be able to build
Up the intellectual head of steam they need to solve complex problems. Time free
From distraction also has to be sufficient to the task. Ask your programmer how
Long he gets to sit and think between interruptions, and you will probably find
It is less than one hour. While some programs can be designed and finished in
Hour, they are few and far between. Giving someone who works for you a few
Distraction-free hours per day is one way to help prevent coder's block.
One of the best ways to overcome coder's block is to look
Another unrelated piece of code.
One piece of advice for all you programmers out there is to touch code first
Thing when you come into work. Do not read email, open your instant messaging
Client, or do anything else that can suck you into distractions that are not
Coding. When you sit down to work, sit down to work. Email, instant messaging,
And social networking are anathema to concentrating on hard problems.
Sometimes coder's block is brought on by programmers taking on more work
They can handle. Either the problems are too complex, or they just do not know
Where to start, or both. I don't know if you have noticed Most coders, But they
Tend to have a large, personal store of hubris that often gets them
Trouble, both at and outside of work. If a programmer is staring at a problem
For hours on end and making no progress, you can ask if he or she has tried
Break down the problem, and perhaps have the person show you how he or she is
Breaking it down. Do not do this in a nagging way that distracts the programmer
(See above). One of the main ways to annoy a coder is to constantly ask, "How's
It going? "You are allowed to ask this once per day, and not when the person
Looks like he or she is actually concentrating. You might want to ask this
Question at lunch.
Another type of coder's block comes from fear of failure. Most people want
Do a good job and be recognized for the good work they do. This is especially
True of people who do knowledge work, such as programmers, because the only
Measures of quality are how cleverly and cleanly they have built something.
Since software is nearly infinitely malleable, inclucoders get stuck trying
Come up with the absolute neatest, cleverest way to implement something.
The need for perfection leads to parse false starts, writing a page of code
And then doing what writers used to do when they had a typewriter writer's
Block: they crumple up the one page they have finally written and throw it in
The trash. When people used paper to write, it was easy to see that they had
Writer's block, because their trash cans wocould be overflowing with crumpled
Pieces of paper. If you picked up a few of these, you wocould see that none
Contained a full page of text; the writers probably got only halfway down a page
Before they tore it out of the typewriter and threw it away. In our modern world
You cannot actually see the false starts, because no one in his or her right
Mind wocould check them in.
If you find a programmer making a lot of false starts at a piece of code,
Give that person something else to work on. One of the best ways to overcome
Coder's block is to look at another unrelated piece of code. You want
Coder's mind to remain in a coding mode but to relax its grip on the problem
That is causing the angst.
Sometimes when people build systems they keep CT are going
Be extended, they place extra space into a structure for future
Expansion.
Finally, sometimes coder's block comes from some sort of emotional problem,
Usually outside the job, although job stress can also lead to emotional
Imbalances. I find that jobs, in general, lead to emotional imbalance, as does
Waking up in the morning, commuting, and talking to stupid people. Sometimes you
Have to just tell someone to take some time off, so that his or her mind will
Clear and the coder's block will lift. Of course, if you find a programmer is
Just staring at the screen, you might want to take a surreptitious glance
What he or she has written. If it is anything like, "All work and no play make
Jack a dull coder, "then it is time to hide the fire axes and call for
Intervention.
KV
Dear kV,
I am working on some very old C code that needs to be extended, but there is
An annoying complication. This Code manipulates an in-memory structure that
Other programs have to read, but there is a requirement that older Binaries
Still be able to work with the new code. I don't think this is possible, since
Once I change the structure the older binaries are definitely going to fail. Is
There a way around this?
Backwardly structured
Dear backward,
There is a small, but nonzero, chance that you may be able to pull this
Off, but it depends on the structure you are working with. Sometimes when people
Build systems they Except CT are going to be extended, they place extra space
A structure for future expansion. Of course I say "sometimes" because although
All computer science programs sing paeans to extensibility, they often leave out
The practical part of just how one makes code extensible.
If you are lucky, then the structure you need to modify has some extra space,
Usually labeled as padding, which you can use for your new purposes. All you
Wocould need to do Is subtract some of the padding and add new elements to
Structure that are equal in size to the padding you have removed. Make sure
Add the new parts of the structure after the preexisting parts, because if you
Do not, then your older binaries will be reading your new type of data where
They should CT their old data to be. That might lead to a crash, which is the good
Case because you will be able to find the bug; but it might simply lead
Getting subtly incorrect results, and those types of bugs are incredibly
Annoying to search out. And make sure you comment your change and be very clear
About the change in your commit message. Messing With in-Memory Structures in
This way can lead to hard-to-find bugs, as I mentioned, and the first thing
Someone who comes internal SS this type of bug will want to do is to try the code
Without your change, to see if it is the source of the problem.
KV
Related Articles
On queue.acm.org
Im, not IP (Information Pollution)
Jakob Nielsen
Http://queue.acm.org/detail.cfm? Id = 966731
Coding smart: People vs. Tools
Donn M. Seeley
Http://queue.acm.org/detail.cfm? Id = 945135
A conversation with Joel Spolsky
Http://queue.acm.org/detail.cfm? Id = 1281887
Back to Top
Author
George V. Neville-NeilKv@acm.org)
Is the proprietor of Neville-Neil consulting and a member of the ACM
QueueEditorial Board. He works on networking and operating systems code
For fun and profit, teaches courses on various programming-related subjects, and
Encourages your comments, quips, and code snips pertaining to his
CommunicationsColumn.
From http://cacm.acm.org/magazines/2011/4/106574-coders-block/fulltext