How do you get things done in hourlong intervals?
JimmyL: When I know I am wrapping up a coding session, I'll often leave a few trivial things unfinished - so that when I sit back down again for the next session, I'll have an easy place to jump right back in, and it will force me to (consciously or otherwise) get back to somewhere near the mental state I was in when I half-finished the thing.In this particular situation, pick what you want to do: get your coding done or visit your friend. If the priority is the former, tell them "I've got some work to do for a few hours, so I'm going to go find a Starbucks and set up station. Want to meet for a drink around <five hours from now>?" If the priority is the latter, then embrace the distraction, spend some quality time/activities with the person you've traveled to visit, and if you must code, keep it to small discrete chunks like bugfixes or writing unit tests.