A question about concentration while writing code.

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

A question about concentration while writing code.

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post 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. :)
User avatar
jyhm
Forum Contributor
Posts: 228
Joined: Tue Dec 19, 2006 10:08 pm
Location: Connecticut, USA
Contact:

Post 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.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post 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 :)
alvinphp
Forum Contributor
Posts: 380
Joined: Wed Sep 21, 2005 11:47 am

Post 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.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post 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.
User avatar
jyhm
Forum Contributor
Posts: 228
Joined: Tue Dec 19, 2006 10:08 pm
Location: Connecticut, USA
Contact:

Post by jyhm »

What about music with no words like electronic or ambient. Some of those help me greatly.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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 ;).
Post Reply