Personal Productivity Stack Exchange is a question and answer site for people wanting to improve their personal productivity. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a question most of us have faced while programming. Getting stuck! It might be a programmatic problem or tool problem, most of us eventually face it.

You know something is supposed to work some way but just doesn't. You tried a number of things to solve it but isn't helping and you are not sure why.

I once remember being stuck hours at programming job. Eventually I figured out for some reason or other my IDE wasn't recompiling my new changes in some of the classes .This is just an example but I am sure most you have faced similar situation.

So how would you go about solving it if you didn't have access to Google or Stack Exchange? Lets be honest, using internet you aren't solving the problem, somebody else is doing it for you. So if you didn't have access to internet or a friend who might help, how would you go about solving it?


A very good article about this topic

More Information : X-Y problem

share|improve this question

migrated from Dec 7 '12 at 13:26

This question came from our site for professional programmers interested in conceptual questions about software development.

I disagree with ", using internet you aren't solving the problem, somebody else is doing it for you". – Luiz Angelo Dec 7 '12 at 12:16
Do you know why we write things down? So that other people who have the same issue can learn from our mistakes and don't have to waste their time as well. If you don't look to others for help, online or offline, you are doing yourself a disservice. In grade school there is this artificial idea of what "cheating" is; in the real world, it's called teamwork and synergy. – zzzzBov Dec 7 '12 at 14:46
"Lets be honest, using internet you aren't solving the problem, somebody else is doing it for you." They sure pay me a lot for having the internet solve all my problems... – KyleM Dec 7 '12 at 18:15
Why on earth was this migrated? – Joshua Drake Dec 7 '12 at 20:40
Some day this question will no longer be appropriate on and will have to be migrated to – Warren P Dec 8 '12 at 1:00

19 Answers 19

Take a break, preferably something physical (gym, martial art class, etc...) or at least utterly unrelated to your current problem. A coffee break is good, so is eating a piece of fruit. Leave you brain to work on the problem in the background so to speak. Then grab your voodoo doll (or more commonly a duck) and explain to it what your are trying to do and how you are doing it.

If that still does not work, look at reducing the problem: remove as much as you can from your current problem until it either becomes clear what you missed or it works. Then work backwards a step at a time.

Mostly, make sure you do not get angry and frustrated. Those are counter productive.

share|improve this answer
I am going to second this answer. I find walking away, taking a break and doing anything unrelated to the programming problem at hand helps my mind clear and then my subconscious refocus on the issue it's own way. I can't tell you how many time the answer would come to me after going to our break room and shooting a little pool or playing a game or two on the XBOX. I haven't done much talking to my duck yet, but he sitting on my desk waiting just in case of emergency. – Akira71 Dec 7 '12 at 12:20
Upvoted for rubber ducking. – Freiheit Dec 7 '12 at 14:35
+1 for taking a break and also talking to your duck. I get my best ideas when taking a shower before going to bed. And I usually end up getting some insights on how to solve it when I try to put it into words for a SO question or an e-mail to colleagues, so talking to your duck should do the same. – Leo Dec 7 '12 at 14:59
Taking a break for sleep/activity is the best way to get over mental blocks, especially if you are working late at night. There were so many times in college that I'd go to sleep, and the next day, all the problems I had the night before magically seemed to go away. Best to program with a fresh brain! – aglassman Dec 7 '12 at 15:46
I consider developing as a solving a puzzle. Sometimes you cannot find matching pieces in a part, then you move and try to work on another part. Usually after a while you found the missing pieces for the original part ! – dawez Dec 7 '12 at 23:25

There is a good technique listed on Wikipedia- "Rubber duck debugging"

It says that you can solve your problem by explaining your program to a yellow duck. While you're speaking and explaining your problems [to a duck, so you have to be very convincing], you may identify the error and think up the solution.

This technique works well if you're stuck. It's a good idea to hold on and think again about all the problem.

share|improve this answer
+1 Also similar would be starting fresh with a piece of paper and a pencil and making it work. Also, you may want to having the reference manuals for the language(s) you're using-- then you're the duck, and the paper has to convince you why the code should work! – 5un5 Dec 7 '12 at 15:37
For what it's worth, your English is better than most native speakers' English on the Internet. – xdumaine Dec 7 '12 at 16:05
Same happens when you prepare an email to ask your colleagues in details about the problem. As you have to explain in detail the problem itself most of the time you found the solution that you are looking for. – dawez Dec 7 '12 at 23:27
I can't count the number of times I've written out a question on Stack Overflow and found the answer before submitting just by explaining the problem in detail. – jontyc Dec 8 '12 at 0:11
This explains why Stack Overflow works so well;-) – PearsonArtPhoto Dec 8 '12 at 13:51

I learned my first real language, C, with infrequent access to the internet and very few books. Getting stuck was invariably a part of my learning process, perhaps the most important part at times. Sometimes, it's good to struggle. This was before the web as we know it came to be known in mass consumption.

When I got stuck, I'd go do the most menial things I could possibly do, because I found it stimulated my creativity. I was also fortunate enough to have a neighbor that was also learning C, so I'd print my code or save it to a floppy and head over to his house to look at it together. When I got really stuck I'd just have to wait until I could get to school and get access to Bitnet. I spent a lot of time at the library.

You do the things you'd do with Internet, you just spend a lot more time and money on doing them. The Stack Overflow of my generation was the computer lab on campus, which was also a wildly successful extortion ring. People paid dearly to figure out they were solving the wrong problem to begin with.

Believe it or not, programmers have been getting stuck and unstuck without the assistance of the Internet for years. You just have to work a little harder at it, and bring extra firecrackers to bribe the ninja in the computer lab.

share|improve this answer
I was going to answer something quite similar to this so I rather +1ed this one. I had very little internet access for the first six years I coded, and I believe these experiences have made me a much better "debugger" in the long run... Also the hundreds of Trace Tables my computer teacher had us do in school :) They get your mind to work in a rather logical fashion (But imho are quite useless for multi-threaded code.) – major-mann Dec 7 '12 at 20:50

Binary search the problem ... that is, break the code halfway through. Is the issue happening before or after this point? Go to half with the problem, break that in half, repeat until you've narrowed it down. Issue found in maximum log_2(lines of code) tries, ie a stupid small number.

Binary search also works for finding a code revision where a new issue started popping up.

It slices, it dices, it makes julienne fries! Binary search today!

share|improve this answer

Before there was stackoverflow etc., what helped us most was the ability to call a friend who happens to be an expert in the area. Therefore, networking (making friends with other programmers, not installing cables) was invaluable back then - and it still is, though more in business matters than in technical questions.

share|improve this answer

So we've eliminated the internet and knowledgeable experts. But there's still the two things you should do before going to the internet/experts. (Unless an expert is readily available and can probably save you hours of hassle with a quick answer.)

First, try consulting documentation be it in books, readme files/manpages/tutorials that came with the program, or reading source code if available. (Grepping through source code is invaluable).

If its a programming problem, I'll probably try debugging to pinpoint the exact location of the problem and figure out what's going wrong. This may be with a debugger or even just adding extra print/logging statements during the debug steps.

If its how to use a program, I do something similar to the xkcd flowchart (yes it includes internet search/asking an expert; but most of the time you do have internet access these days and why cripple yourself):

xkcd flowchart

share|improve this answer

You always have your life lines. Ask the audeince, phone a friend, etc. And of course the good ole library, whether you own a book or not.

The internet is a great tool, but man made it to the moon without it!!!

share|improve this answer

First, you need your 'sanity check' - stick some debugging output in your code to say 'Hello World X' and you'll confirm immediately that you are:

  1. Editing the correct file
  2. The compiler is listening to you
  3. You are running the correct file!
  4. The code is actually reaching the point you think it is and the problem is really where you think it is.
  5. A myriad of other stuff that can send you insane

Once that's in place, use the binary search others have been referring to - try and find at which point the logic of your program breaks down. There's a crappy old programming language called Eiffel that made you have 'assertions' before and after every branch or logic statement - e.g. before and after your IF statement or outside and inside of your loops. Crappy in its fastidiousness but very useful guidance if you're debugging a stubborn problem.

If that doesn't help, break out the cardboard developer/rubber duck - talk to your dog, your little brother, your wife, your rubber duck, whoever is available and step them through what the program is supposed to be doing from the start. Explaining the problem to someone clueless to help works amazingly well and at some point while you're explaining the program/problem you'll go 'AHA!' and figure it out.

I would add that stack traces, visual debuggers etc all make things a lot easier these days but I still remember when Google got all the old bulletin board archives and stuck them up on Google Groups - the ability to get answers AND code SPECIFIC to what you were working on right now was AMAZING...

And now we have stack overflow, even better...

share|improve this answer

take out a piece of paper and draw your code.

for each routine, create a picture that represents the input and output of each method.

now go back and look at your code. debug/trace your way through the code. ensure that every single piece of data is exactly as it is in your picture.

once you inspect it, you may see that the code/data does not match your picture. then the answer is obvious.

(i presume that you can trace/debug your code and inspect variables - aside from compiling/executing your code, it is the second most important tool to a programmer)

share|improve this answer

In some cases this problem can arise in the workplace. If this is the case for you, talk to your employer and explain that to get the best productivity out of you, it will be necessary to grant you at least limited internet access. Many internet filtering tools are available if the employer is concerned about time-wasting, including cloud-based ones that require no software installation or maintenance.

If this problem arises at an educational establishment, on the other hand... as a student, you should see yourself as a customer. Demand to know why the best source of knowledge the world has yet produced is not available to you on the premises!

share|improve this answer

In case when something doesn't work for me I try to make it work in a different language/paradigm.

I normally do a scientific work in python. Sometimes I can't figure out why a bit of code gives me wrong results or does not give them at all. As in python I often use classes, I try to perform the same task in a language which does not use classes as the first choice (Matlab/Octave or R in my case). Also I breaking down the problem to small pieces. So in my second language I don't rewrite whale hundreds of code but only a bit making it a simplest possible.

I have to admit, in most cases it does not finish in full code. After starting to think in different paradigm I often start to tweak my original solution and it turns up to be correct.

If I can't figure out why it does not work it means that my way of thinking is wrong in the first place. I have to take a break from the problem to catch some sort of distance. I try something different enough to get rest.

Obviously there are some other ways. Sometimes I going to my friend from my office and ask him (often on phone or skype) if I can explain him what I am doing only to check if I am clear. I don't expect his advise, only understanding. Often he ask questions like: "why you doing this, this way" and often I find I can't answer this question and this is the problem to fix. Sometimes after paraphrasing a whole story I have my solution seen from a different angle at it helps me to solve the problem.

There are also methods to do it by your self, taken from NLP etc. but the basic idea is to paraphrase, work in different paradigm and communicate out your ideas.

share|improve this answer

This is what I do, grab a pen, paper then analyze the problem. Jot down some points of your approach. If it's a programming problem, rewrite algorithm, and try to implement it in the language you know. You can find a solution.

The answer to this question, varies according to the environment you live-in, and it's debatable. If you have descent network of people around you, you can probably get ideas, by asking them. What if there's no Internet or stack-exchange ? However, first source of solution provider is your approach to the problem and your effort.

share|improve this answer

Lots of answers point to a very traditional approach for general code problems, debugging whether with a formal debugger or a with a manual strategy that mimics debugging.

Another well known way to approach a code problem is to write an automatable testbefore you even look at the code in question. Maybe write two. Maybe three. Design your tests to isolate the aspects that contribute something to the problem function. Then write a few for that particular function, with varying values for the contributions (use some variation in the contribution: known or expected 'good' values, and known or expected 'bad' values. Exercise the function in a manner that you would if it was being used for real, but substitute or fake parts that are extraneous.

Other problems, perhaps with tooling or runtimes, are often configuration issues. Perhaps certain environment variables are needed and normally set, but something about the environment setup changed and those values are no longer defined. Perhaps a single security patch or security policy change did the damage (eg host/port restrictions, permissions, ownership). The important thing is to take note of whether or not that if until now, everything normally worked, and if so, what changed, even if it may on the surface appear unrelated, it still may have indirect but significant consequences.

One time while working on a COBOL project, the C tooling was upgraded. Shouldn't be an issue for me? But it was. A particular version of a library from the C package was necessary for certain aspects of the COBOL runtime process. This dependancy was only one of many of the C package files that were updated, but it was still important, and not part of the 'stated' requirements for our COBOL package. And while the issue was relatively easy to address in our development environment, the same solution wouldn't work on the client/user machines, so we had to change how our software was linked and distributed.

If it worked before, and anything changed, and it doesnt work now, the anything should often be the first culprit.

If something was changed, but the effect wasn't apparent in the outcome, it might be a stale intermediate build file, a stale cache, any other locked file, or stuck process.

If it worked before, and absolutely nothing changed, I often move to looking at hardware. Cables securely and properly plugged, free of significant knicks or abrasion that might result in short-circuiting or interference or worse. Ram test, drive checks, etc. Parts age and fail. Dust and heat are mortal enemies of electronics. Is the machine of concern in a mostly ideal environment for the computer and is proper dust preventing and removal performed.

share|improve this answer

Ask help from others. As programmers, we have a certain pride in our abilities and in solving our problems ourselves. However if you're going nowhere, and your schedule is suffering, then it's time to ask help. A fresh pair of eyes may have the answer or may point you in another direction.

Also, step back a bit and give yourself a break. I've solved some of my design and programming dilemmas thinking about the problem during my bus ride to work. The stress-free, relaxed, and unrelated work-setting has enabled me to think more creatively.

share|improve this answer

Here is yet another approach, which is very similar to the scientific method (if not the scientific method itself).

The steps are

  1. Realize you're wrong: if you have a problem and you can't find it, there is something you don't know.
  2. Start breaking down what you know.
  3. Identify the most likely of those assumptions to be wrong, make sure it is relevant in some way to the problem you're hunting.
  4. Fact-check it.
  5. Keep doing this until you find what you were wrong on and how it applies to the problem you were trying to solve.

Keep in mind when fact-checking something that it may not be productive to figure out things on your own. Learning is definitely great but you may not want to learn a whole new science to just confirm something. This is where your best time usage is to check references, internet o colleagues.

I wrote a detailed article based on this answer. It also uses a development example but it can be applied to any other area. How to find the problem?

Note: I hope I'm not breaking any community guideline here. I added this link thinking it actually adds to the response. If this is seen as self-promotion, feel free to edit the answer and add relevant portions eliminating the link.

share|improve this answer

I agree with "take a break".

If I want to continue doing something mentally challenging I pull out my tablet and read some articles from my reading list (using the pocket app with offline sync).

share|improve this answer

On the C# side of things, I use tools like ILSpy to check out what's going on or even how a feature may have been built out it.

share|improve this answer

I had the same situation , try to finish what you can do , assume that you did the hard parts 'by making a fake data or result that you are expecting' , then when you be able to access internet find a solution to the hard parts then apply it and test your code.

share|improve this answer

There are so many ways to solve a problem.

  1. taking a break
  2. talking to a duck or writing the issue
  3. searching the solution on internet.
  4. backtracking
  5. split the code to find which code execution is creating a problem.
  6. understand the issue, the big why?
  7. get the domain knowledge of the language or third party library as much as you can.
  8. write your options related to the different tools of the language, one thing can be solved with different ways.
  9. use a debugger
  10. discuss the problem with peers.
share|improve this answer
Does this add anything over and above the existing answers? – Rory Alsop Jan 2 at 22:46
@RoryAlsop It's a good summary. :). – Sathyam Jan 3 at 0:42

protected by Rory Alsop Jan 2 at 22:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.