views:

220

answers:

9

This is not a technical question, but rather a social and methodical one. I am a computer sciences student and I usually have really tough programming assignments. I don`t know if it is only happening to me but sometimes, particularly when deadline is approaching, i find myself in a harsh situation. I cannot find my mistake in the code or come up with a another great idea. Then boredom comes in and the problem begins to seem unsolvable.

I know there are more-than-great professional coders here. I would like to learn their ideas to cope with this situation. Is it better to focus on something else for a while and try again or try harder and harder and look for the solution on the net etc...

A: 

A similar question has already been asked here http://stackoverflow.com/questions/427532/what-do-you-do-when-youre-stuck.

Sleep is my personal favorite though, although if you're like most college students, you're probably doing a lot of last minute coding and you don't have enough time to sleep and submit your work on time [I was guilty of this too].

sjobe
+4  A: 

Sleep is good, or if not sleep then at least taking a break, going for a walk in the fresh air etc.

Brainstorming the problem with colleagues / fellow students can help. Even just explaining the issue to someone else can be enough to make the solution click in your brain.

Failing all the above, ask on Stackoverflow :-)

Vicky
Stackoverflow is really great but when you have time:D Thanks btw because this is a total answer that unites all given answers.
Ersan Tasan
+7  A: 

I alway like talking about the solution with another programmer. Just talking makes me use a different part of my brain and most of the time I hear myself talk through a solution.

Christopher Altman
That's an interesting idea. But are they always enthusiastic to brainstorm on it because if it is a real challenge then they need to sacrifice some time on it?..
Ersan Tasan
@ersan - many people love to hear issues, solve problems and help others.
Tim
@Ersan Tasan: The point is that you have to explain your problem. This helps clarifying your thoughts and find a solution. You can talk to your cat if no other programmer is around.
mouviciel
@mouviciel: Cat? Strange idea, but good... Then you think it`s not about getting answers but trying to recapture and materialize the problem.
Ersan Tasan
Talking also forces you to be patient and explain yourself clearly.
Christopher Altman
+2  A: 

Try breaking down the problem into smaller, easier problems, and solve those. Don't try and tackle everything at once, and avoid trying to hack your way through.

If you're still stuck, taking a break can be good. Sometimes the answer is suddenly obvious when looking through a refreshed pair of eyes. Solutions to problems often come to me in my sleep, and I'll wake up knowing the answer.

fearofawhackplanet
That is exactly what I experience sometimes. I seriously think that the brain works differently when waking up. It kind of has a better problem-solving power.
Ersan Tasan
A: 

What I like to do when I'm stuck on a problem, I usually try to draw out my problems. I just get myself a piece of paper and write down the problems that I encouter. While doing this I like to make Class diagrams/Sequence Diagrams, just to clearify the situation in. Really helps to just get back to old skool pen and paper and not look at your screen for a while.

Bas
Should be really helpful I suppose. It also may help with the eye restrain that screen causes.
Ersan Tasan
+1  A: 

For me, I encountered a couple of times where I took quite a bit of time (10 to 30 mins) to define the problem in writing as to submit the question on SO, and got ideas that led to the eventual solution while typing out the question.

I find that when I document your problem in a way that others can understand without having to understand the unrelated parts of the your entire application/project, I consciously break down the problem into isolated, independent parts which helps me or another developer analyze and decide the next course of action.

Just my two cents :)

Mr Roys
+1  A: 

In your case (school work) I would probably seek out the instructor/professor or TA. While they will certainly not "give" you the answer at the very least you might learn something else in the process.

Specifically I would explain to the the difficulty you are having, what you have done to try to solve it and any other things to show that you did work.

A lot of times while walking though this on your own you might come up with solutions. They can probably give you hints or suggestions as well.

Worst case scenario is that they tell you to go away and to leave them alone.

Tim
+1  A: 

Others have posted sleep (@sjobe, &Vicky) and asking someone is good (@Christopher Altman). BTW, that is often referred to as "rubber-ducking".

My personal problem is wanting to see something through and getting consumed in getting to the finish, almost always to my own determent. What I've learned over the years if a little research doesn't help (< 30 minutes) and talking it through doesn't explain it and you can't or don't want to sleep on it, do something for the mind, body and spirit: Go outside!

Seriously, go for a 30-45 minute bike-ride, run, walk, swim, whatever. Try to think of something else. Tell yourself a story or mentally work on another problem if you must. Cool down and return. You'll be amazed at how refreshed you'll feel. The endorphins will help.

If you're embarking on career driving a desk, it's a great habit to get into as well.

-Cheers

DevSolo
A: 

As a student I also face this problem from time to time. What helps me quite often is to get away from the computer, take a pencil and some paper and start to write down the code by hand. I don't know why but often it is easier for me to solve it on paper than by using an IDE/editor. Probably because your brain works differently then.

Helper Method