Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't even know if this question makes sense ... but let me let you grok it...

imagine ... You're totally absorbed into some programming thought/idea/concept, your brain is in it's most active state thinking up a solution to a problem, or as Joel Spolsky puts it -- you're deep into your "zone" -- AND, suddenly someone or some event breaks your engrossment -- something that you just can't avoid, something you have to attend to. ... imagination complete .. back to reality

Something that can break your concentration can be...

  • you're summoned for an urgent meeting
  • your code broke the daily build and your colleague is calling you
  • you just recalled something you had to do but forgot doing it
  • your teammate has some exciting news to break and insists you to listen
  • your girlfriend (or boyfriend) has just come over

Now assume you've got only 5-10 minutes before you have to leave what you were deeply into, and entertain the interruption.

My question is -- how do you, quickly "save" the state of mind you were in, when the diversion came. Do you write it in "some form" on a paper or computer, or do you just "remember" it somehow. How do you salvage those exact thoughts within 5-10 minutes so that later on when you come back you can catch up right from the "point" you left.

It often so happens to me that i just can't recollect those exact thoughts i was thinking before the blow -- and i feel like i've lost a good idea or solutions to a problem. i try to think retroactively trying hard to get to that SAME cognitive state that had me excited about an idea -- but i get frustrated not being able to "get there".

does something like this happen to you. how do you "recover" from this?

-- UPDATE --

My main concern is not code -- it's those "abstract ideas" that haven't been yet converted into code that i need to "save" somehow

share|improve this question
I'd recommend using a mindmapping tool, like FreeMind. Or Emacs Org-mode. Both are convenient for quick editing of TODO-tasks and ideas as they come. (and back them up to a source control system to access them from anywhere) – haylem Jul 27 '11 at 23:48

12 Answers 12

up vote 14 down vote accepted

Before leaving my PC I'll write what I was doing down on a post-it or on a piece of paper. I'm usually doing this anyway as a part of a bug fix or analysis. It's really helpful when a bug is (re)opened later, you can still see your lines of thought of a month ago and find out what you have to do a lot faster.

Also: set some bookmarks in your code. When you come back you can look at what you were doing by viewing the bookmarks you set.

share|improve this answer
+1. In my experience, the act of writing down what you were doing is clarifying in and of itself, and helps even if I don't find myself referring to what I wrote later. – jimwise Jul 27 '11 at 13:32
+1 i agree, writing it down in "some form" is the best solution :) – treecoder Jul 27 '11 at 15:45
+1: There's all kinds of cognitive research to support this. It's like taking written notes when listening to a college lecture. The more parts of your brain you can engage at the moment, the better chance you have of hanging onto the details. – Bob Murphy Jul 27 '11 at 22:16

I whip out the local notepad application and write down my plan of things to come.

I've found this to help the most. 100% of the time I can't remember what I planned to do when I come back, ideas are easy to come across but do you remember the actual steps you were going to do?

I use something like;

+ Fix i.d bug
    - look at first name , problem?
    - ...

+ Deploy changes to test database

+ Come up with production deployment plan

I save it to the Desktop and keep the file open.

I found this, for me, has these benefits;

  • It takes 5 minutes
  • It's easy to get back into the 'zone'
  • It trigger's memories more easily
share|improve this answer
that's what i do also -- just thought someone could have a better idea :) – treecoder Jul 27 '11 at 15:44
I don't know if there is a way to 'save' a perfect 'image' of your ideas at that time. But I will put in key words to help bring back that entire though, and think about that idea and associate it briefly with those words as I write them down. Another idea, when this fails is diagrams, and I did this a lot when programming a 3d engine as a hobby. This way I could visualize my ideas or my final goal, save them on paper and come back and even do better than when I left off. – Ross Jul 28 '11 at 0:42

This happens all the time! When I'm in the middle of writing code, I can tell 90% of people to wait for a few seconds - they know it's in their best interest not to disturb me. During these couple of seconds, I intentionally mash some keys on the line of the code I was working and mark the line above with XXX (this highlights nicely in vim).

The mashing of the code is done so the program won't compile and I'm forced to look at that line. For most of my languages that I write in, this is sufficient enough for me to look at where I left off and jog my memory into its productive state quickly.

I've also learnt that being in "the zone" is now a luxury these days (from dealing with constant interruptions). While it's definitely not ideal in terms of productivity, it forces you to make the most of whatever you have.

share|improve this answer

In addition to the excellent suggestion of writing things down, this is a skill that can be developed with...


I used to be the world's worst at multitasking. People used to dread interrupting me because I was so unpleasant about it. Then I realized it really wasn't like a CPU with multiple parallel cores, it was like an interrupt with task switches. So I started training myself to relax to it and accept it as a necessary part of life.

A decade on, I use a Pomodoro-like system where I simply take a break when the timer goes off. It's amazingly easy to get back "in the zone" in a relaxed environment after a few minutes' break - I look forward to it! And for longer interruptions, those written notes are invaluable. I can restore almost all of that mental "CPU state" pretty easily now unless more than a day goes by.

Also, because I'm now more used to coping with interruptions, I'm no longer such a grouch when people do it. I've also gotten much better about simply saying, "Hang on a moment while I make a note." It's amazing how much more pleasant my social interactions are!

The brain is like a mental muscle, and it gets better at things like multitasking if you give it progressively more difficult workouts.

share|improve this answer

I've found out that whenever I work with git, I have less trouble with leaving work behind (and more importantly, continuing working on it). It's not because of git itself but the practices I've adopted when learning git workflows. I'm talking about topic branches.

If you do all meaningful 'wholes' in your development in a dedicated topic branch, it is much easier to come back to your work. Here's why.

  • topic branch provides context. You've given it a descriptive name, so you know what you are looking at.
  • history has smaller and more linear scope. As you work on smaller change sets (branches), you probable have less commits to go through, and they will be linear (there are no non-related commits in between)
  • if you delete topic branches when you're finished with a topic, it is easier to understand what topics you have been working on, and more importantly, which still require your attention

If you have discipline, this way of working makes it much easier to leave your work and pick it up later on.

When I'm working on something, I always come up with somewhat related work to my current topic. Again, having a discipline pays off. Either finish your current work. If you can't (I often have this 'problem' - 'I need to fix this now' etc.), just create a new topic branch for the fix (or refactoring, improvement, whatever). Even if you're current workspace is not ready to be committed, just do git stash, do the small work in it's own topic, and pop from stash to get back to your actual work.

share|improve this answer

For preserving state of task and switching to another, I absolutely love Mylyn context preserving. What Mylyn does is store and later restore exact state of your IDE (open perspective, open files, location in these etc.).

For things I was doing, I put TODO comments. Eclipse automatically shows these as task list.

share|improve this answer

I develop in a VM. And when I'm interrupted, (end of the day, lunch, meetings, etc.) and don't want to lose my train of thought, I just write a comment in the code, something like:

//Figure out how to implement "Date range too far out" check correctly

Sometimes these comments go on for a few lines, if it's complicated. But I just write the comment in the code, in the IDE, then leave the IDE open and use the "Suspend and Exit" command on the VM. Then when I pull it back up again, there's my comment right in front of me immediately, which helps me quickly get back to what I was thinking about before.

share|improve this answer

I've taken to using mind mapping software (currently FreeMind). I use it for everything, but relevant to this, it includes a to-do list for each project I'm working on. As I'm thinking out a solution to a given problem on the list, I start typing it out inside my mind map. That's where I store my solution, even while I'm working on it, instead of trying to hold it all in my head.

That let's me focus my mind on code implementation details, without losing the overall picture. It also means that interruptions have minimal effect on my work, because I keep the steps I'm planning to follow recorded somewhere anyway.

The specific software or tracking method you use is irrelevant. This idea would be just as useful in Notepad or with a piece of paper. The relevant concept is that you are recording your ideas as you have them, so they're always available.

share|improve this answer

If you are in a high-interrupt environment, I find keeping an hourly journal (write down a couple bullets every hour) to be very useful. I use a combination of TiddlyWiki and paper (Tiddly for documenting/searchability, paper for quick thinking).

I started doing this when working from home with an infant and it increased my productivity across the board. It helps with the immediate problem of rediscovering my thoughts, and has a nice side effect of increasing my self-awareness (I spent an hour on modifying a 10 line bit-banging method last week to make it more readable. Probably not the best use of my time).

share|improve this answer
+1 thanks for TiddlyWiki -- i've used it previously but never thought i could use it to quickly "serialize" my thoughts :) – treecoder Jul 27 '11 at 15:43
@greengit - I get a lot of mileage out of it. I keep my journal, solutions log, and backlog in it. I use it to do performance evals. I do a lot of one man R&D where projects get worked on for a few weeks every year (before demos, naturally) and then shelved again. I'd be lost if I didn't have a way to back up my brain. I like TiddlyWiki because it's still personal and I don't have to write to the level of formality that I would for a company wiki or doc that anyone should be able to understand. – Steve Jackson Jul 27 '11 at 15:54
so do you recommend the desktop version (the default one) or ccTiddly -- which is the server backed incarnation of tiddlyWiki – treecoder Jul 27 '11 at 16:01
@greengit - I use the desktop version and a cron job to back it up to a network share. I haven't used the ccTiddly version, but it looks like most of its functionality is covered by the project wikis we have in place for collaboration on projects. ccTiddly does appear to hit one of my wishlist items - the ability to attach files to tiddlers - but I paste links as needed. – Steve Jackson Jul 27 '11 at 17:23
  • think out loud in a developer's log document as you go
  • brain-dump into the log when you get interrupted
  • make sure you write down the next thing you were going to do

the former is insurance against interruptions, backtracking, and repeating yourself later, while the latter is essential for picking up where you left off

share|improve this answer

I keep a running commentary in a notepad beside me. I tried to do this on a notepad file but for some reason it doesn't work quite as effectively as writing it down. If you're reasonably organised about what you note down as your working, you effectively have a coredump of your abstract thoughts to come back to.

share|improve this answer

What I found helped a lot (even for "OK, now I go home and come back to work tomorrow") was constantly jotting down the top several thoughts in my mind, and then doing stuff off that list.

But it definitely relies on (i) actively processing that list -- at a minimum purging it rather than ending up with hundreds of half-finished "todo lists" that you mean to go back to and (ii) practicing enough you have the experience to know what you need to write and what you don't -- which tasks have "add toolbar button" and the details of design you can recreate out of your mind next time, and which tasks you've done half the planning already without realising it and you need to jot that down itself.

Also, obviously, try and avoid unnescessary distractions; it's always good to be able to continue over a distraction, and there will always be some, but don't encourage too many.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.