I have heard it said that Hacker News is successful because procrastination is a constant problem for programmers. So if you do get a free block how do you get into a state of distraction free programming? If like me you aren't naturally good at blocking distraction, there is a system that has worked for me.
Naval Ravikant has identified on the Tim Ferris Podcast that winding up and winding down is one of the unique challenges of our time. His prescription is meditation and while I agree, I think the format is key. When I am working through a problem, I, like many people get that sudden urge to check and email, twitter etc . So the most important programming habit I have developed so far is how I react to that feeling.
Initially I tried meditating but got quickly distracted from it by the level of anxiety I was feeling about not getting anything done. What I eventually realised is that I was starting the meditation too late. The second the urge to break starts, its time to close the eyes and breathe and engage in a type of short term meditation for 5-10 minutes.
I now do this regularly during programming and although initially it felt like I was losing time, it has led to much greater productivity. Very unscientifically, the best indicator that I am relaxing well, is my eyes start darting under my closed lids. It feels like REM but could be unique to me or imagined.
In terms of winding up, I actually think it is a misnomer. For me, Winding up is getting into a productive 'zone', which is a habit built over time. And so to get good at winding up, I had to slowly build my consistency from 10 mins of programming up. The best way to do this was to join a class, or get a mentor who will automatically worked with me for an hour. From there I began to extend either side of the class.
The same thing has applied to winding down. It didn't work, felt frustrating and seemed pointless at first, until I set my expectations lower and just aimed for consistency over outcome. Getting good at longer meditation sessions seems to have helped me 'drop' into a useful 10 minute session pretty quickly.
And so managing my expectation for meditation has been the best way for me to improve programming concentration. It doesn't always work, but has certainly helped.