21

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 its 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?

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.

-- update --

After these many years, I can confidently say, there's NO possible way to do this. No amount of scribbling your cognitive state onto a piece of paper will allow you to restore it exactly the way it was. Our brains are much more complex than a measly snippet's worth of scribble, when it comes to the information it holds actively at any point in time.

The best way is to avoid the distraction, no matter how important, unless, it's a life and death situation. Nothing is more important than being in the zone and finishing it.

If your workplace is naive enough to not appreciate someone's "being in the zone", then time to look for a new workplace. YMMV though. And with the personal relations, it's social skills and a pinch of articulateness that can do a world of good.

  • 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

13 Answers 13

19

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.

  • 2
    +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
  • 2
    +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
  • Notebook for me and I though I do it as I go along, then I cross them out when done. Also I'll leave partial code with intentional compile errors with a message of what needs to be done. – Newtopian Dec 11 '17 at 14:39
8

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
  • 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
5

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

Practice.

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.

4

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.

3

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.

3

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.

2

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.

1

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.

1

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).

  • +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
0
  • 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

0

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.

0

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.

0

I've actually caused several bugs as a result of being interrupted hastily and abruptly for lunch breaks at a former company. I ended up asking for a few more minutes or just leaving without me only for them to pressure me into joining, and so I left the code half-written, the thought half-complete, only to return to the code an hour later and lose track and get things wrong.

I ended up starting to compensate for it by taking notes and writing out todo lists as I go and just maintaining a "shallower mental stack", so to speak. TDD also helps since the tests express what you're trying to do with a design as well as ensuring you're doing it.

I have also developed a language that is somewhere between what intuitively seems to me like coding and human language. It consists of sounds like, "Nyargh! Bloobly-bloop!" and I make those sounds sometimes if people are trying to talk to me while I'm busy. While they don't understand those sounds, it communicates that I am in a state unable to properly communicate with humans at the moment, at which point they walk away and allow me to resume thinking and writing code.

That said, my wife has gotten used to the idea that she might talk to me and I might be nodding and so forth and have not mentally processed a single word she said. It's like I can see her mouth moving and hear sounds coming out but it's not really being translated properly into machine instructions. She has kind of learned to notice my responses when that's happening while I'm absorbed in thought.

I also sometimes halfway process what she said and just push it to the concurrent queue, like if she asks me a question, at which point I can't fully process it until I've popped everything off my mental queue (which uses very inefficient locking mechanisms for thread safety). So she has gotten used to asking me a question with only a nod and no response or a nonsensical response like "yes" or "bloobly-bloop" to "what do you want to do tonight?" only for me to process it ten minutes later and answer the question as though I just heard it a second ago.

Also I don't know about you guys but I get really absent-minded when I'm lost in programming thoughts. I ended up looking for my socks one time for ages, forgetting where I put them. Somehow I put them in the refrigerator. I think I was trying to grab a drink or something with my socks in hand and somehow put the socks in the refrigerator and forgot to grab the drink. At another time, I went to a garbage dump after parking my car with my car keys in hand and tried to throw a wrapper I had into the garbage. Instead I ended up throwing my car keys into the garbage dump and I didn't even realize it until I tried to unlock the car with the plastic wrapper, at which point I had to dive in the garbage for my keys. Anyway, my wife is used to these types of things with my stuff appearing in odd places.

[...] your girlfriend (or boyfriend) has just come over

Just for this part as an aside, dating and romance is difficult with programming. I had many past relationships where dating went wonderfully until we started living together and they saw that side of me lost in thought all the time while sitting all day at the computer and pacing around in thought while responding with "bloobly-bloop!", and lost interest. It's tough to find someone with the patience for that. I got really lucky with my wife who puts up with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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