During programming you might find difficulties on solving some complicated arithmetic code. What is the best way to approach?.
Take a break. Work on something else for for half an hour.
Set out an amount of time to keep trying something... if your not getting anywhere after that amount of time, try another way and repeat.
Finally; post on StackOverflow :P
Well. Most of the time I dont feel distressed when I have to solve some complex coding problem. Reason is that I love coding. But, at times, it surely irritates me. Then I take a brake. A walk. Or I watch some tv. Or I just take a walk and smoke. Just to reboot my brain, to start in a fresh way.
Break it down into smaller chunks of thought.
When under pressure it's easy to only see the big scary monster in front of you. However if you take a closer look and see where you can break the hard problem down into smaller achievable problems, often a lot of the pressure will dissipate.
Commonly, most of the pressure I feel is pressure I put on myself as I over complicate my thought processes. Which then creates a negative feedback loop, increasing the pressure.
Break the loop, take a break etc. Come back and ask yourself does it really have to be this complex?
As others said before, taking a break usually helps. Psychological research has found that your brain keeps working on the problem in a parallel 'background thread', which is the reason why you often get a sudden insight when taking a walk during a break after you've been struggling with the damn code for 2 hours.
I usually try to hook up with a like mind (either online or in person) I know, if possible in my team. Explaining the problem not only helps the other one understand the problem, it also helps myself, since explaining forces me to think about the structure of the problem.
Writing tests is another way to make yourself think about the problem in a structured manner. For strictly arithmetic code, I usually write some unit tests that check for known input/output sets (output prediction).
Personally, I would take a break, find a quiet time to pause even for just 5 mins. It is really helpful to just let your mind rest for a while and before you know it, the solution will come to you!
Another way is that I sleep it off and not think about it until the next day. I found out that if I pressure myself too much from finding the solution to my code, I am prone to mistakes, and this would be a time waster because I have to go back and correct it again.
If I'm still stumped, I ask colleagues or as Pace has said, post your problem here in StackOverflow or any other forum groups... I'm sure that you will get an answer there! :)
Hope this helps!
longer hours, and more coffee.
that or start putting 'smart' drugs in the coffee machine and hoping you work mates start creating some impressive code.
Here you have given tags as programming and interview questions, so my answer would have two part.
Part 1: Coping with Pressure while Coding at Work
Normally on programming job, pressure is mainly related to meeting Deadlines and so Project Manager should plan out Project in a very efficient way using best planning tools at hands and should divide and delegate task to individual developer depending upon their skill set and their experience as ofcourse you do not want to give iphone programming task to PLSQL Developer and so that is most important.
Now once the task has been allocated to all team members, you have to make sure that you understand what has been assigned to you. You need to understand Big Picture of the Project and how your particular module will fall into Project. You should know your deadlines and plan out your task accordingly.
Rarely things go as planned in Software Programming Estimates but you should have a rough estimation which would give you and approximate idea about the task and time you can allot to each task, by doing so you will not end up in a situation where you have release in 3 days and you are still lost somewhere in the code and unit testing is left, integration testing is left, normally when this kind of things happen than people take unit testing for granted and think that QA will find out if something is wrong and than later wew will fix it but that approach is not good as it will degrade quality of Software.
So bottom line to cope with pressure while coding at Work is to plan your task list against allotted time and so you will not end up in tight schedule.
As the saying goes, Prevention is always better than cure but that being said if you really end in tight pressure condition with release within a week than roll up your sleves and start coding here the concept of team comes into picture...at our company when we have tight deadlines to meet than we all get together spend some extra time at work, by extra time I mean some extra nights, we have pizza's, coke and we all really get together as team to meet the deadline and our Manager's is also there with us coding and it really feels good and this way team spirit helps us alot to reduce the pressure and by far I see that this is the best way to deal with Pressure.
At our company, we are not alone at successful software release and also we are not alone working nights being depressed to meet deadline, we work in team and share the spirit of Team both in success and in failure.
Part 2: Coping with Pressure at Interview
While at Interview, I would suggest that one should think on problem at hand rather than thinking about how others would feel or see your approach, your first priority should be to think of problem at hand and should be cool and calm while approaching the Interview Problem.
One should have ability to think about things that are really necessary and important at that particular time rather than dividing focus on some unnecessary things.
Hope this helps.
As someone said Divide and Conquer: Break Problem to its simplest case and than try solving that simple case first and do not get into negative thinking that it is not possible. Problems are meant to be bit tricky or else they would loose their reputation of being a problem.
Thanks.
Motivation and Technique has an interesting answer on this that basically boils down to 2 questions:
- Why are you doing it? (Motivation)
- How are you doing it? (Technique)
If you are poorly motivated that can be a bigger problem than the coding challenge before you, while if your skills aren't adequate that can cause its own level of headaches.