
Ask HN: how strong is your focus when you are coding? - hoodoof
It seems to me that the stronger my focus, the more productive I am when coding.<p>However it is very hard to remain tightly focused.  So my programming productivity swings wildly as does my focus.  I am trying to become more productive when I code, so I'm trying to train myself to remain focused for longer.<p>I'm interested to hear the thoughts of other people.  How strong is your focus when coding?  Do you get long stretches of focus and productivity?  Or do you keep losing focus and having to work to bring it back?<p>Also, how old are you? I'm interested to know if it's easier to focus on coding when you are younger.  I'm 45.
======
xackpot
It's easy to lose focus while coding and quite natural too. I usually follow
these methods while coding:

1\. Write down the goal for that day that I need to accomplish before I start
coding.

2\. Break down the goal into mini goals.

3\. Take a 5 min break after each mini goal is met. I usually just get up and
look out through the window or do some light physical activity.

4\. Before starting for the next mini-goal coding, I sit down and think how I
am going to code.

5\. Start coding while keeping the goal of the day on the top of my mind.

Personally, instead of coding, I believe that I am writing a poetry and unless
I get the lines correct, I won't be able to write a beautiful verse.

There; I don't have to worry about focus.

I am 36.

------
X4
I've the "talent" to not care about environment/sound and noise, because I
thought myself to focus & learn while my classroom went mad. When I start
coding on something I forget time, eating, drinking and everything else.

This is a real horror-story that happened not long ago:

A handful fire-wagons and police cars were outside. My mum called, the door
ringed, but I didn't hear anything due to the focus. I just complained
silently about the lights that blinded my eye from the window. Suddenly I
realized that it's night and that it wasn't the sun, so I asked myself what
that was. And realized that the worst thing that can happen got real. I was in
burning building, alone, coding. During the high-focus I was in the "FLOW".
The building got evacuated, because of the fire. Everyone was outside, sirens,
police, firemen, but me. Nothing happened to me luckily and the firemen could
kill the fire in time, before it spread. The cellar had to be renovated.

Yes, I was very productive, but you can see the danger of that.

I learned from experience though that I can be similarly productive and stay
more conscious when I hear music with low volume that contains no vocals. DnB
for example, but I don't hear the music consciously enough to be selective
about the genre.

Because I know better now, I do sequenced high intensity programming sessions
of not more than 60min and separate research sessions with a time-limit.

~~~
hoodoof
Wow. You must get alot done. What are you building? How old are you?

~~~
X4
Thanks for the kind works, but it can be a plague, when you cannot stop doing
what you do easily..

The environment you work on OS/Laptop Speed/Workflow is really crucial to be
effective. Currently development stalled, because my laptop broke a little and
isn't pushing anymore. Gotta get a new one.

I build meta software, concepts, software architecture, servers and
experimental UIs. I'll try to work on ai projects to unite some projects
without building glue-code after my current project. Step by step.

------
gregn
I struggle with getting started on a project. I tend to spend days, sometimes
weeks, thinking about the problems I am going to have to face when I start
coding, and researching them. Then it happens. I sink into some sort of trance
from which I am unwilling to wake from. People ask me to social events, I
decline. I can stay in this frame of mind for well over a month if the project
is important to me. I had a professor who said that it takes three days to get
into the coding state of mind but once you're there you are in a higher
productive mode of thinking. The only problem with this, as everyone knows, is
that it is very easy to get shaken out of the state. Then you must spend
another three days to get back into it, which is why programmers are often
reluctant to break their focus - it wastes time.

It has gotten easier to enter high focus mode with age and experience.

I second techno music. Aphex Twin. Prodigy and NiN have been boons for me in
the past.

I am 40

~~~
hoodoof
I have this problem too - I definitely just need to get started writing code
to break the trance. I force myself to start solving easy problems which
naturally gets me into the flow.

------
lukethegeek
22yo coder here - my focus is patchy or fragmented at best and I procrastinate
like a trooper.

I'm capable of decent stretches of focus/productivity when the moon & stars
align - er - when I have the right energy levels and can fully mentally
comprehend the task at hand (best properly planned and broken down into
manageable chunks as xackpot said).

Isolating earbuds and some upbeat music help me focus. IMO regular breaks are
a must to keep mental exhaustion at bay, especially in a career like
programming.

I don't force myself to focus if my brain just isn't cooperating, since I just
start making mistakes and any productivity evaporates. I just go and do
something else for a while before trying again.

Really, I don't think that there's a 'one size fits all' answer. You just have
to try different things and see what works for you. You may (or may not) be
able to significantly improve your focus (I never could), but I learnt to get
the most done with what I have.

------
Cryode
I'm 28. My focus sucks overall, but a recent improvement I've made is the type
of music / noise I have while working. I switched from music I really enjoy
and tend to sing/hum with, to electronic music with little to no vocals and
upbeat tempos. My mind focuses less on the words and music, and allows me to
think more about what I'm doing.

I've also tried some white noise creators, like this one for coffee shop
sounds: <http://coffitivity.com/> Personally the techno music works better,
but you may be different.

------
MichaelStubbs
21-year-old here and while I don't get into "the zone" very often, the times I
do generally result in 10+ hours of solid work.

I find that music really helps, yet I'm not a fan of the shuffle function in
music players. As a result, I guess you could say that I lose focus frequently
but quickly regain it. My fussiness in regard to music is something that I
need to work on in general.

~~~
edh649
Hmmm. I would suggest maybe listening to some 'new music' so to speak. Put one
of the soundcloud 'discovery' genres on and just leave it playing. You
probably don't like the shuffle function as you get to a song you don't really
like and you want to skip it. Or you get reminded of another great song and
that album and want to put it on. With new music you'll just think "it's
okay", "this is awesome", "this is bad. hopefully the next one will be
better". You aren't reminded of other songs and previous ideas so it doesn't
interfere with your work.

------
xcbnxcbxmcb
I'm almost 29 and I've written a lot of code over my life-time. Having spit
out copious amounts of code for over 10 years now, I don't think productivity
in a larger sense declines with age. Physically or in terms of life
priorities, writing code all-night long is not so much fun anymore, but any
reduction in energy is made up by a higher efficiency due to experience. At
least, that's the way things have been so far!

I definitely have productivity swings (and I make myself feel better by saying
they're akin to moood-swings and out of my control!) Productivity is highest
for me when I'm in a highly structured environment. I've churned out insane
amounts of code when

a) I knew exactly what needed to be done and b) Had a sharp timeline to
complete it

#a happens externally sometimes, when requirements are crystal-clear. For
example, when you build stuff on <http://community.topcoder.com/tc> Otherwise,
my approach is to spend as much time as needed in order to clarify
requirements. I simply do not bother to code unless I'm sure about the end-
goal.

#b can be seen in hackathons, or when a team / startup has committed to a
demo-day (it can also be artificially imposed by managers)

When both #a and #b are externally satisfied, I can code all day long without
problems. Things like headphones (to prevent interruptions) are useful but not
necessary unless the environment is extremely distracting.

When #b is satisfied but not #a, I try to reduce the uncertainty around
requirements - otherwise jumping in to code and then having to throw it away
can be killing. At some point, the RoI in trying to achieve more certainty
will get negative, at which point I start coding with whatever I have.

When you have #a but not #b, it is very easy to procrastinate. Of late I'm
inspired by www.structuredprocrastination.com (brilliant, short read) to still
maintain productivity.

Finally, having neither #a nor #b is the worst. Being in startup mode for the
last few years I've seen how difficult that is. I'm making my own version of
productivity pr0n, inspired from Marc Andreessen's blog post
<http://pmarchive.com/guide_to_personal_productivity.html> The most effective
thing for me is to plan a day ahead and then actually log what happened in the
day. Just the act of measurement goes a long way in lifting mood and
productivity.

------
speedyapoc
I'm 17 and started programming three years ago. I noticed that my mental focus
has declined a fair bit as the daily grind and my work has become easier and
easier. I generally code in 30 minute bursts (or more, depending on the time
of day, my mood, etc). The more challenging the task, the more focus I have.

------
tadpole1
I am 34 and was recently hacked if not data mined. I want to learn programming
from the grass roots. Where do I start? This subject has stolen my entire
focus, and I obsess a bit. Where do I begin?

~~~
edh649
Choose a language. Any language. People will try to convince you that X
language is better than Y language but really it's your choice.

Now you've chosen a language, go and find some basic tutorials. Start with
'Hello World' (as per tradition) then work your way up, make a counter, make a
calculator, make a clock. Just keep on doing these basic projects.

Soon enough you'll start to get bored. You'll start finding these projects
easy. You'll no longer have to look up every line of code to work out what
syntax to write, you'll just get used to it. Once you get to this stage, start
looking for what other people have done. Look for a basic application that
someone else has created and start to work out how they made it, their
programming style. Once you've worked it out, try modifying the program. Trial
and Error. Try to change what the program does, try adding on new
functionalities.

Finally, create a big project from scratch. Start with an idea, it can be
simple but try and make it challenging. Work out how each part is going to
work, how you're going to code each bit. Then just get programming.

Once your first project is done, you'll most likely have another idea, and
another. You'll keep on programming new things, each project learning
something new.

That (at least in my opinion) is how to learn to program.

------
ibudiallo
I can nly focus when I have a challenging task. My small tasks usually take
longer to complete that's why I love interns.

