It is called "Hidden Stress", the person who experiences this is unable to realize actually he is under stress and only able to see its outcomes after it becomes too much, like i was experiencing. Resulting in disorder even for basic daily stuffs. |
To be honest I don't see how "The problem i am talking about is being too focused on one thing. How can i overcome this problem?" turned into "Hidden Stress" and am really doubting your friends assessment of the problem you are having. Though then again I am not a Psychologist so take my opinion with a large gain of salt.
Though for your specific example and how to overcome doing this again I would definitely agree with Disch about using a debugger to find the problem.
Also worth noting is trying to keep your code as modular as possible. This will help greatly with debugging the code when errors happen, since when something goes wrong with X functionality you know exactly where to start debugging because most if not all of X's functionality is all grouped together nicely.
Another good habit to get into is testing frequently. Implement some new functionality? Go create a test for that functionality right away to make sure it is working right. Try to do this as often as possible. It is up to you to find your preference, I like to do it after every new function I write, or any group of code that needs to preform a certain task. This might seem a bit tedious at first but in the long run it really helps eliminate a lot of the errors right when they are introduced instead of finding out about them days, weeks or even months down the road (Or even worse not finding them at all). I also find it more fun to program this way since I can see the results of my work much sooner.
If you find you like this kind of workflow I would recommend doing some research into "Test Driven Development" and some unit testing frameworks. It is a different take on development but definitely does help with eliminating errors more effectively.
And lastly I wouldn't get to hung up about this problem, I am sure all of us have done this more times then we can count. It just is a matter of experience in my opinion, after you keep programming for awhile you will run into the same types of errors over and over again, which will allow you better judgement from past experiences on where to look to fix it.