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.
This would heavily depend on the kind of problem at hand. A compiler getting stuck is a different thing from finding some function in a large library or not remembering the exact syntax for some command line tool. From that view this question is far too broad and does not really make much sense. – thorsten müller – 2012-12-07T11:30:43.703
38I disagree with ", using internet you aren't solving the problem, somebody else is doing it for you". – None – 2012-12-07T12:16:50.937
20Do 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 – 2012-12-07T14:46:17.520
5"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 – 2012-12-07T18:15:31.830
5Why on earth was this migrated? – Joshua Drake – 2012-12-07T20:40:09.477
Try walking your dog while you're thinking the problem through. (He probably deserves a break, too.)
You can try the "scare the bug technique". In this technique, you discuss the problem with someone else, and the mere threat that there are more eyes on the problem will often cause the bug to succumb. (If you have no one but a dog to talk to, you have to be clever about it. Don't let the bug know!) – Jim – 2012-12-07T21:28:33.163
1If programming existed before Internet there should be a way to fix things. Find a quick solution all the times is preventing to learn the fundamentals behind the problem. When you know have a solid knowledge about something than you should be able to find also solutions. Anyway it is normal in development world that you got stuck on something [it's easy if you know how] – dawez – 2012-12-07T23:20:29.467
6Some day this question will no longer be appropriate on productivity.stackexchange.com and will have to be migrated to lackofproductivityduetogettingstuck.stackexchange.com – Warren P – 2012-12-08T01:00:11.897
I find it interesting that some would find searching/researching answers and solutions a way of not learning. I wonder if I was to read a book that taught solutions, would that mean I wasn't learning either? As far as syntax goes, this is details not based on a deep understanding of programming. Even still how do we remember spelling except for looking at it and performing it constantly. – galford13x – 2012-12-08T02:52:53.697
1Fun fact: As soon as I read the question I thought about migrating it to programmers.stackexchange.com – 0x6d64 – 2012-12-08T11:06:16.923
I would favorite this question, but then when I needed it, I wouldn't be able to pull it up on the Internet. – Kevin – 2012-12-09T17:25:34.197