

Ask HN: Overcoming coder's block? - matthewcford

I was wondering if anyone has any good tips for overcoming coder's block.
======
barrybe
1) If you find yourself trying to design features and write the code
simultaneously, then try breaking up those steps. Get away from the computer,
grab a pencil & paper, put your designer hat on and go to town. Then drop the
notes by your desk, grab lunch, come back, and act like you are implementing
someone else's design.

2) If you have a design but are just trying to figure out how to implement it,
then TDD can help a lot. Write a test that checks if your thing does what it
is supposed to. Then run the test, it should say you have X failures. There,
now you have a concrete problem to solve: you need to fix those failures.

3) If you are intimidated by a large coding problem, try instead to just make
the simplest possible prototype version that just barely works. Even if this
exercise causes you to write throwaway code, it's worthwhile. Once you have
something working at all, it's easier to think about the features that you
need to add to make it finished.

In general I think people get blocked when they try to solve too many open-
ended questions at once. So try to break apart your problems into bite-sized
pieces, and find ways to turn your open-ended questions into specific,
measurable problems.

------
pavelludiq
Thats a hard one. Zen and the art of motorcycle maintenance talks about the
concept of a gumption trap <http://en.wikipedia.org/wiki/Gumption_trap> and
how we might get out of one.

With me, its usually normal to feel "down" for some amount of time from time
to time. I usually use this down time to sleep and relax, im probably not
gonna get any real work don, so i might as well rest.

I have a lot of non coding "projects" for times like this. Usually its a book
im reading a few pages at a time, or a list of tasks i might as well do NOW,
since i have noting better to do. Maybe a list of bands i should check out.
Basically anything that goes in the "check out later when you have more time"
category, this is the time. So you do that stuff and relax and wait for it. It
usually lasts a between a few hours to a whole week in my case. I don't mind
it, im in school, so i can actually afford not to write code, i just show up
for lectures and try to think of cool stuff to work on, eventually it comes to
me.

Actually im in such a moment WRIGHT NOW, which is unfortunate, because the
little free time for coding i have is on weekends.

------
davidw
Go for a bicycle ride (or some other exercise).

~~~
hoprocker
You get the added benefit of endorphin-fueled contemplation of the project
you're working on.

------
blue1
Some things I have learned:

Make a big, approximate plan of everything you have to do. Take the first step
and detail it, dividing it in little, non-scaring tasks. Then start working on
the first. While you are working on one, concentrate on that and forget about
the big map.

Seriously divide work and non-work life. During the non-work part, completely
forget the work. This is actually beneficial for work too.

Never sacrifice on sleep.

If you notice that you find difficuly in starting a new task on your list at
the beginning of a work day, try closing your work day by leaving something to
be completed (but that you know how to do it). This helps bootstrapping the
next day. But don't think about it all the night!

If you feel that coding is becoming boring and repetitive, escalate your
skills a little (enough to make things interesting, not enough to cause
panic). Learn metaprogramming.

------
macemoneta
A good night's sleep.

------
jgalvez
First, go for a walk. Everyday. No excuses. 1 hour minimum.

Then, stop trying to work at the end of your day. Start working within the
first 6 hours of your day.

Tea is awesome.

And if you're into it, cannabis is a great concentration/inspiration aid, but
just a couple of hits, you know. Otherwise you get too wasted and won't code a
thing.

~~~
pwmanagerdied
_takes notes_

------
andhapp
I normally change the technology I am working in and move to something else or
just pick a random topic and read about it as much as I can and then as
matthew said do a blog post on it. For example: State machines and Ragel state
machine compiler.

------
chaosprophet
I had a similar issue sometime back. Here's what people on HN said:
<http://news.ycombinator.com/item?id=876674>

------
matthewcford
For me it's writing blog posts: <http://matthewcford.com/coders-block>

------
known
<http://en.wikipedia.org/wiki/Test-driven_development>

------
bemmu
Sometimes the "block" just means you aren't actually all that into your
project.

------
stuartjmoore
Draw it out.

------
ComputerGuru
Music.

------
DanielBMarkham
Two things:

1) Understand whether you are blocked on a design question or a coding
question. Is the problem you can't find the answer or the problem that you
can't make the answer happen in code?

2) Purposeful distraction. Sleep. Go for a walk. Play a FPS. Learn to distract
yourself for short periods throughout the day. When done correctly, this gives
your subconscious time to work on the problem. When done very well over a
period of days, it "ramps up" your problem-solving skills.

I'm starting off a small project this weekend. After a few hours of coding
last night (my first coding session in a while) I got blocked.

So I went to sleep.

As I slept, in my dream (or when I was barely conscious, hard to tell) I
realized what I needed to do next. When I woke up I was ready to get at it.

The trick is to make these times purposeful (not random procrastinating) and
to never try to code your way out of a design block. Sometimes problem-solving
is best approached like night vision: you see the most at night by not looking
directly at the thing you're tying to see.

Hope that makes some sense.

