Page 1 of 1
A question about concentration while writing code.
Posted: Wed Feb 07, 2007 5:47 pm
by impulse()
For the 6 months I've been writing any PHP code I always find sometimes, mainly when working with complex loops, that at points I totally lose focus of where I am meant to be going with the code and then spend 10 minutes backtracking and then come forward a bit. Also sometimes when I'm stuck on a problem I find that I figure the solution and then forget the problem and know that I have the solution. Is this a common thing when writing code? Or is it something that passes with experience?
All thoughts welcome.
Posted: Wed Feb 07, 2007 5:58 pm
by RobertGonzalez
When you code your comments (yes, I said code your comments) you have a tendency to be able to quickly pick up where you left off.
Posted: Wed Feb 07, 2007 6:40 pm
by superdezign
Yeah, readability is the purpose of comments.
Also, it helps to stay organized. The only time I've lost track is when I'm really hungry, leave to eat, maybe watch a movie, and then come back. And even then, comments keep me in shape. Just be sure to describe what you want your functions to do, and then along the way, how it gets it done. As long as your code is organized, it should be easy to deal with.
Posted: Wed Feb 07, 2007 9:13 pm
by seodevhead
You sound exactly like me. And I hate to say it, but it may very well be A.D.D.
I am notorious for doing things such as, going in trances, looking out the window, taking LOTS of 20-second breaks where I will go to 5-7 news sites, look at the headlines, then come back to coding. Then 1 minute later, repeat the same process with those SAME 5-7 sites thinking that perhaps new headline news is up. Then another minute later, repeating yet again and so on. Maybe its a mix of ADD and compulsiveness. Either way, I have it... you might too.
Just chock it up to your style of doing things and cope. Years ago I tried the medication route, with no success... so now I just set aside more time to work, knowing I zone out a lot more than the normal joe.
For some reason I am "in the zone" for about a good hour or so right after taking a shower. I guess it "freshens" me physically and mentally, so I now take 2-3 a day. It helps me do a lot more work and feel better throughout the day.
And lastly, a tip from my doctor that works... if you don't have any distractions, you're mind will create its own. If you only have one distraction, you will focus on it, however if you are overloaded with distractions, no one distraction can get a lock on your focus. So here is the tip... Turn on 3-4 radio stations in the room you work. You won't be able to single any one station out, and hence your mind won't work against you to target any particular distraction.
It is kinda like trying to read a book in a very quiet room with 2 people whispering off in the distance. That is far more annoying and bothersome (because you want to hear what they are saying)... than if you were reading that book in a loud and busy auditorium where people are all around and voices are blending together.
I probably just made myself sound like some freak, but oh well. I'm sure I'm in good company here on that front.

Posted: Wed Feb 07, 2007 10:01 pm
by jyhm
I find it hard to get motivated for a project sometimes. When working on a new problem I become obsessed with it and I'll stay up all night or wake up thinking about the problem and immediately log on to my system. But when the initial thrill wears off and its time to implement the rest of the project, I start looking for distractions. The only thing that helps me get back into it is doing very small bits at a time.
Posted: Wed Feb 07, 2007 10:29 pm
by alex.barylski
I find I get de-motivated when:
a. The challenge is gone
b. The code begins to feel ugly (code smell)
At this point I typically stand back, print the code, sit on the couch and begin refactoring on paper. This usually jazzes me up again and within the hour I'm back at the screen refactoring the codebase (new challenges) and I goto sleep better at night knowing I don't wake to a mess in the morning...
I also find code cleaning something which stimulates me when I just can't be bothered to write more code...
Cheers

Posted: Wed Feb 07, 2007 10:48 pm
by alvinphp
impulse, i don't get the problem you get at all. With proper use of OOP, good commenting, and high level UML's I can pretty much stop at any point of development and pick up where I started without too much confusion.
Posted: Wed Feb 07, 2007 11:03 pm
by daedalus__
I have a lot of similar problems. I have a very short attention span. I may work with 4 different languages in a day, in addition to doing Sysadmin work, graphic design, publishing, advertising, reading news, writing poems, smoking a cigarette, whatever. I usually can only work on one thing for about 20 minutes, any longer than that and I am either in the zone or grumbling.
If you have ADD or something what seodevhead said will work very well. Unintelligible background noises usually help me concentrate, as backwards as that seems.
Posted: Wed Feb 07, 2007 11:12 pm
by jyhm
What about music with no words like electronic or ambient. Some of those help me greatly.
Posted: Wed Feb 07, 2007 11:36 pm
by Kieran Huggins
Try different methods of working - maybe plan out a map of your program on paper then implement it one piece at a time. Could help re-focus you when you're done one section / module.
Posted: Thu Feb 08, 2007 12:37 am
by Chris Corbyn
Unit test.
If you are developing inline with a set of tests you can pretty much pick up where you left off. And yes, of course, OOP makes things a lot clearer cut since you'll find yourself writing smaller morcels of code at any one time.
Posted: Thu Feb 08, 2007 4:00 am
by Maugrim_The_Reaper
d11wtq has it right - I find it very easy to get back in the "zone" when unit testing, or more accurately when employing test-driven design (test first). Even if you forget what you were up to, any problem you had would already have been covered by a test (hopefully). So if interrupted or distracted, when you go back, click refresh on your browser tab holding the test results output, you'll have either a fatal error or a set of failing test descriptions to get back on track.
I also find my attention limit at 20 minutes or so if the code is not all that challenging. So I usually have two or three tasks moving in parallel so I can switch over and focus on something different, or new for a few minutes. I actually prefer coding in relative silence - I might have something playing in the background without words but it's more an exception to the rule and usually only in the evening when it's getting a tad bit TOO quiet

.