Overcomming Programmer's Block?
goingware asks: "What do you do if your productivity drops to two lines of code a day, and you just sit and stare at the code and feel like you don't know how to do it anymore? On the outside, it would seem my problem is that I've got some difficult architectural issues that I'm wrangling with. I'm not sure what the right way is to approach a certain feature I'm building into my program in C++. But what my real problem is that I just sit and stare at the computer all day long feeling scared and anxious. I'm afraid to try anything out at all for fear of making a mistake. I know I could just back up the code and write any old thing and throw it away if it's wrong, but for some reason knowing that doesn't help." What do you do when you are stuck in code and your focus leaves you? This isn't something as easy as getting up from the problem for a while (although that helps), this is sounds like something closer to burn-out. What can programmers do to combat this?
"I've encountered this before, but it's not normally like me. I've been programming as a career for something like 13 years now and shipped dozens of products. I've had many obstacles before and overcome them through many and various means... means which all escape now.
Right now I feel like a clueless newbie assigned the task of re-architecting a nuclear powerplant control system.
This has really got me down. I have a product to ship. I called my client and asked to take a few days off from coding, and told her I'd be hitting the C++ books and taking a rest and trying to rejuvenate my programming creativity. She was OK with this. So part of that process is posting my question here."
One thing I've noticed is that simply working longer hours doesn't normally make me more productive. There seems to be a two or three hour surge of activity, after which I have to take a break - read some newsgroups, go for a walk, whatever. In these situations the "leave it and come back to it" approach really works.
If the problem still looks bad when I get back to it, then the next thing I do is ask a colleague for advice. In situations where there isn't another programmer around, I simply describe the problem to any willing listener. Often the simple act of talking about a problem elucidates the solution. Now this is going to sound silly, but I've even talked to my cat when working at home and sometimes had that "eureka" moment.
If the task is simply beyond your ability, then it's time to admit it - approach your manager and say so. Grit your teeth and accept that no proprammer can do everything. Just hope that your boss understands that. If you lied about your abilities to get the job, then I've no sympathy for you (having fixed cock-ups by such people). Otherwise, if your boss is able to do his job properly, then he should be able to see this is a resource issue - not a general failing in yourself.
I've actually quit a job because I felt the task I got given was beyond my abilities - finding some comfort in the fact that programmers are a scarce resource. While it is a drastic course of action, I felt almost europhic knowing the stress was over. So if it's not just burn-out consider getting out of the job.
Chris
This is not exactly how I do things at my work, but there have been ocassion where I have introduced code of my own into the knowledge base of work. (don't worry, I have a clause in my contract which states the company and I will share intellectual property so I won't lose a damn thing)
Doesn't anyone make flowcharts or other software and data diagrams before they launch their text editor? Assuming you're writing new code and not debugging, why are you staring at the screen? Coding anything vaguely complex off the top of your head is Not Good.
Stop thinking in C++. Start with the big picture. Map out the problem. Then drill down to the architecture. Then drill down to the core functions of each module. Then firm up your data/object models. Next, drill down to the detailed design. Most of this should be boxes, arrows and lines, not code.
Then, and only then, start doing serious real coding. If you wing it, you're liable to get stuck or produce something pretty unwieldy.
In my case, I find that a lesser banishing ritual of the pentagram helps.
Mutatis mutandis for your own faith.
The Tyrrany Begins....
Finding God in a Dog
So, when I built my box for home, I had them install a nice ethernet card for my little LAN, but I kept the modem out. And the difference is pretty amazing. Just dis-engaging my mind from the computer, going outside and thinking about problems without the computer staring back at me is quite refreshing and helps my creativity immensely. The computer is just a tool, after all, and sometimes one needs to put aside the tools to get a better look at the problem.
Ita erat quando hic adveni.
Given the way scientists were treated in those days when they tried to suggest that they knew things that officials of the church didn't, don't you think that terminating your essays with "Of course, I believe in God, and this is all God's work. Actually, this proves that God exists. Isn't God great?" could be motivated by self-preservation rather than severe belief?
When atheism is oppressed (as it has been through most of history, and still is in much of the world), practical atheists give lip-service to religion. When speaking other words, or even remaining silent, would likely be punished, one's words are no evidence of anything at all.
BTW, Newton was a remarkably ruthless and pragmatic person who is known, as a matter of historical record, to have told lies often, and about many things, for his own benefit.
---
Despite rumors to the contrary, I am not a turnip.
Finding myself unable to code, I started writing the code in english on paper. I would sit down in a corner of the room and start writing in english. "check the user permissions. if the guy is an admin, show this and that screen. for each line in the screen, make sure it's bla bla." and so on. Once I was done and saw that I had something that could work, I took the text, pasted it into the existing source code and started translating it to code (Java in this case). Maybe it won't work for everyone, but it did wonders for me and I was able to overcome my block several times this way.
So I think you did the right thing by riding it out, reviewing fundamentals, letting the solution present itself to you of its own accord.
If you think of writer's block as a boulder in your path, you can extend the metaphor to how you go about destroying it: You can either flail away at it with a sledgehammer, expending enormous energy to make slow, painful progress; or you can study the rock, learn it, find the cracks, insert the chisel and destroy it with two or three taps. It is rather Zen. When you are not actively typing away at a problem, you are gaining awareness of its true nature.
So use your time of stuckness to do good things, and if you work where your manager says things like "I didn't hire you to think, I hired you to work", buy him a copy of Demarco and Lister's Peopleware and tell him to go away and come back when he's read it.
Note: The above links to Amazon.com do not imply endorsement of them. Support your community's independent bookstores: read Amazon's reviews of these books, then purchase them locally.
--
This is not my sandwich.
The Slashdot crew isn't the mostly likely group to go hit the weights, but for me physical exercise really helps keep my mental side running smoothly.
Endorphines and what not, I guess... Plus it helps get your body tired so you can get longer, more restful periods of sleep. They've done lots of research showing heavy exercise can overcome some mental problems like ADD, and that is the same mindset I end up in when I feel blocked...
Best of luck.
I too have been programming professionally for over a decade (in C++), and here's what I've learned:
Don't be afraid to fail.
Sometimes, the problem definition is too vague, or there are too many unknowns in the mix. You have to follow the scientific method, and the first step of the scientific method is gather data.
You have a module that you cannot figure out how to do? cvs commit, then say to yourself, "Self, we're going to write something to see what is what. When we are done, we will delete what we have written, and using what we've learned, write it properly". You'll be amazed at how much clearer the hidden requirements become when you start bashing code against them.
Now, as to the C++ issue: I don't know if part of the problem is your level of skill in C++, or if that is just a red herring. If you really aren't comfortable using OOD, then for Torvalds' sake DON'T! Just write the code proceedurally. Again, I've often found that once I've written a code block, I can then better see where the objects are within the code. Then, I re-write the code to be OO.
In my experience, no object is reusable from the beginning, no matter how much work you put into it, no matter how long you worked on the design. Only after the third time a class has been used have you come close enough to defining what functions need to be virtual, what members non-private, what args need to be passed to the constructor, etc., to make the class really reusable. Accept it and move on.
Like I said, don't be afraid to fail. It's the only way you will succeed.
www.eFax.com are spammers
What do you do when you are stuck in code and your focus leaves you?
:)
Bail out - become a manager - it's worked for so many others - how can it be wrong?
But seriously:
In one place I worked at, we had a standing rule - if you were bogged down, it was better to just pack up and go home for the day. Get out, get some R&R and get back tomorrow to resolve the issue.
This came about mostly 'cos I had a couple of occasions where, after pounding at a problem until late at night, I'd give up and go home. I'd be half way home when I'd realise what I'd done wrong and, turning around, would race back to plow through the issue.
So, it was not uncommon to hear a defiant "SCREW THIS AND THE HORSE THAT CRAPPED IT!" from the development area followed shortly after by a resolute programmer storming out of the office. Usually within an hour the person would be back with a solution.
Worked almost every time...
I left my body to science, but I'm afraid they've turned it down...
But you probably already know that. And I already know the cruelty of simply telling someone not to fear. I'm no programmer, but your problem is universal.
You are finding it difficult to work. This is because, as you perceive it, the risks of continuing outweigh the benefits. You may explicitly tell yourself that this is not so ("I know I could just back up the code and write any old thing and throw it away if it's wrong"), but the horde of automatic thoughts that rise up when you contemplate doing it say different. You know that in a long-term sense, bearing down and getting through the work is the best thing by far. But when an individual's fears of failure become strong enough, it can force hir out of the long-term perspective and into a low-level, immediate world, the same way that you can be stopped from contemplating Rodin's Age of Bronze by a splinter. This is the point where you might just be told to shut up and work through it, but another way is to figure out what your fears are, whether they're reasonable, and whether they can be disproved or transformed.
If you were trapped in a situation where the alternatives were painful, awful failure and procrastination, your solution would be to procrastinate. You must acknowledge that this is reasonable. The first step is not to blame or criticize yourself, which only increases your paralysis, but to compassionately accept that you're in a bad situation and start working to get a handle on it. It sounds like you're already on that road.
Now, we have to find out why you're fearful and emotional about this project and whether it makes sense to be that way. The simplest of all tools in my field of study is the double-column technique. Just think about the automatic thoughts that go through your mind when you contemplate working, and get them written down on the left-hand side of a sheet of paper.
I don't know what your thoughts are, but for many people they may look like this:These are frightening. Are they true? In fact, they contain cognitive distortions that all people make to some extent. The second and third show the especially insidious error of dichotomous thinking, the tendency to see things in an all-or-nothing sense. A single failure could be due to a specific hole in your education, emotional factors outside your work, a lingering virus, or all sorts of things. But even if you completely and utterly screwed up, would that erase thirteen years of success? Surely that makes no sense!
On the right-hand side of the sheet, write the best refutations you can think of to these statements. They should be compassionate, insightful, and constructive -- everything you'd tell a friend in your situation. In this example, they might be:Keep your refutations with you at all times, and write them down as you think of new ones, or notice new automatic thoughts. What you have to do is take the most powerful and frightening thoughts you can uncover and argue them down. I mean seriously argue, bringing up the best refutations you can and trying to believe them wholeheartedly. Even if you don't buy them now, think how much more productive they can make you. This isn't really dishonest; if this rational optimism leads to repeated failure, you can always re-evaluate it and change to thinking you're a washout.
Fear and self-criticism are terrible motivators. Relaxed understanding allows you to work with an absorbed sense of flow. To put it tersely:
chill.
- Michael Cohn
Important note: I am a student, not a licensed or degree-holding psychologist. I am giving you a digest of other researchers and writers. This may be valid self-help advice but should not be relied upon for severe or life-threatening problems
Recommended reading on the subject of Cognitive-Behavioral Therapy:
Beck, Judith: Cognitive Therapy, Basics and Beyond -- a textbook. Dry but comprehensible.
Burns, David: Feeling Good -- a self-help classic. Burns is a moron about a lot of things, but it's overflowing with useful techniques and arguments.
Ellis, Albert: A New Guide to Rational Living -- If you're sick of therapists who act like Deanna Troi, you'll be pleased when Ellis comes and kicks you in the ass.
-----
Go ahead, blame me... I voted for Nader!
One means of stirring up the creative juices is to walk far away from the computer and pick up a good magazine (like Scientific American) with articles from a wide variety of backgrounds. It can be useful if you're an engineer, for example, to read articles from biologists or astronomers to give your brain a kick in a different direction...
Stop by my site where I write about ERP systems & more
I know the author has spoken, and a holiday has provided the answer for him, but perhaps someone else who is really in a rut could try what I did.
I changed everything about working with computers.
For years I used to specialise in programming VB and Delphi apps in Windows (don't laugh, it paid the bills), and I was really in a rut. I had tried just about everything using those languages, and there was no very much left to interest me.
So I made a big jump. I switched to Perl. I got a new job programming in Perl as a trainee consultant, and after 6 months solid learning, I still realise that I am only scratching the surface.
Life couldn't be better. I'm having challenges again (I also switched from Windows/IIS to Linux/Apache), there is lots to learn, and the fun that I used to have when I was playing around with my old ZX81 has returned. Coding is great again.
Find funky gifts
Caffeine is EVIL
No, really.
It might seem like the problem is a particularly tricky algorithm to implement, or a bug that you can't track down, but this is never, ever, really the case.
The problem is Stress, and if you (I'm more addressing this to the clueless replies than the original poster) don't admit that and deal with it, it will just get worse.
A charge of Caffeine won't prep you to handle tougher problems, it will just make things feel even more hopeless and impossible. If there is any wonder-drink that will sort you out, it's a Smoothie, made from fresh fruit, that contains lots of de-stressing anti-oxidants and natural sugars.
Another wierd viewpoint I've seen in this discussion is that when you get burn-out, you should take a couple of days off and then dive right back in. DUH! Why not adopt a lifestyle you can maintain indefinitely??
Through my degree I tried all sorts of things that I thought would directly increase my productivity - Coke, ProPlus, Guarana - and they all just served to make me more stressed, depressed and non-productive.
What really increases productivity is having a rest and doing something different. I always try to:
Do something small at least every hour
- Go to the toilet
- Go fetch a smoothie
- Go and have a chat to someone
- Pray (I ain't religious, but I see that this would help) or meditate
Do something longer two or three times a day- Lunch OUT of the office
- A walk in the sunshine
- Watch a movie
- Have sex (on your own is just fine)
- Play an instrument
- Have Exercise (trust me, there IS a worthwhile sport for you, even if it's just a walk in the park)
Take the weekend off- Veg
- Tidy the house
- Dig the garden
- Go visiting people
Duh, people tell geeks to get a life. Sometimes we don't even look after the one we've got.My problem usually stems not from hard architecture problems, but instead from bad specs. I design web applications using PHP. I will often go on binges where I work 15-20 hours straight take a nap and go back at it. Those are the time when I am told to go and "just do it". But if I am given a handful of poor specs, and then somebody is looking over my shoulder asking me to redo every other feature or function I have a tough time gaining momentum to get any productive programming done.
For me its all about momentum. The more I code the more I want to code. If I have to keep shifting gears, by attending meetings, writing reports, etc I can't shift my brain into gear. Then I am left in limbo, usually checking my email every couple of minutes and making sure slashdot hasn't posted a new story.
Fortunately for me I work at home, so I can avoid most distractions, but it usually takes me at least a day to recover from a day in the real office.
just my $.02
-MS2K
I find it helps to stop and pray, even if just for a minute. I lean back in my chair, put my feet up on my desk and ask God for inspiration. It's helped me out of blocks many times. Of course, I liked the comment about becoming a sys admin too. :) I actually do both so when I get tired of one I do the other. It's 4:30 AM here in CA and I've been coding an inventory proggy since 10 AM. At 1 PM I get a break to install a frame relay!
T. Bradley Dean
tbdean
Recently I've been experiencing the same! I've been calling it "programmer's fatigue". There are probably a few programmers out there that believe "programmer's fatigue" can't be experienced by a REAL programmer... well screw off and blow it out your far heap. I've been programming for 17+ years and its not exactly 'programming' that I'm fed up with. It's the application I'm working on! It's gross, and the spec is completely out of control.
In my experience, I need to be utterly interested in what I'm writing in order to be good at it and turn out a great piece of software. Perhaps you aren't interested in continuing your project... there are obsticles in the world that software can't solve. Screwed up software design specs are one of 'em.
If you're bored with the current app your working on, find something of better interest, and you're productivity will surely pick up again.
--cr@ckwhore
Skiers and Riders -- http://www.snowjournal.com
I know this sort of thing well. I get it myself often.
My solution is simply to switch to a different project for a while. It always works for me - I work well on the other project, and then when I go back to the original work, I'm more motivated.
I haven't really analysed why this works before, but I think it's maybe because when I come back to the original project, I've forgotten some of the details of how it works, so I have to study the code again; that's a great motivator (for me, at least) because I spot bugs and stuff that I would have missed otherwise, so I start fixing them, and that breaks the "programmer's block" syndrome.
By the way, I'm also a writer, and the same thing works for me with that too (although I usually have to leave it alone for a bit longer than with programming projects).
(Spudley Strikes Again!)
The only solution I ever found worked was to change the working environment. Your skills and talent are still there, but you've become bored or intimidated by the surroundings. I find that taking a scratch-pad and a pencil and going to work in a coffee-shop works. For serious cases, I go work in a bar - they're usually quiet during the day and a couple of stiffeners tends to loosen up the inhibitions that are causing the problem.
-- AndrewD
A Maze of Twisty Little Laws, All Different.