Context switching. Computers are great at it, humans suck at it.
Every time we developers lose the context of our current task we're forced to waste precious time getting it back. The harder the problem we're trying to solve, the longer it takes to reinstate its context in our mind. This is why many developers strive to reduce interruptions, set aside large blocks of time, and create an environment that helps them get into the flow and stay there.
The problem is, there are times when we absolutely must leave our development context behind and pick it back up later. Sometimes it's 30 minutes, sometimes it's overnight. I find these times very frustrating and have found a few techniques that help me quickly get my flow back upon returning.
1. Note to self
Leave yourself a little note saying what you were up to. This is probably the most obvious technique, and can be quite effective. The problem I've found with this is that I often forget to do it or am just too tired/lazy at the end of the day to do it consistently.
I need to write myself a note to remind myself to write myself notes. Guh, yeah.
2. Always be failing
Leave one or more tests in your test suite failing (you are writing tests, yes?). When you return to the project your first step is to run the test suite and you'll see the failing test(s). This one works really well, but much like leaving yourself notes it's something that you have to actively participate in. It can actually take more time and effort to employ than leaving notes.
3. Git dirty
This is my favorite and most oft used technique. Leave your Git (or the DVCS of your choice) staging area in a dirty state.
When you return, you'll see all the changes you most recently made before you left off. This, combined with a quick perusal of the commit log will quickly bring your context back. The advantage of this over the others is that it is somewhat participation-free. Simply fail to commit your last changes and they'll be there waiting for you. At least for me, this is far more likely to happen than technique #1 or #2.
4. ???
Those are a few things I've been doing to get my dev flow back quickly, but I'm sure there are others. Do you have any tricks up your sleeve? I'd love to hear 'em!
Top comments (22)
Never leave code to be commit-ed in your machine... you may end up to learn it in the hard way, like when your disk breaks apart and you loose all your precious work.
I use ZSH shell that have pretty handy git alias:
So my workflow is:
gwip
to commit all dirty changes, including untracked files, therefore everything.git push origin feature-wip
to push my changes to a work in progress branch. This saves me in case my disk goes dead.When I am back to the project:
gunwip
to get back git to the same exact dirty stage it was before I appliedgwip
.When I am ready to perform a clean commit:
git checkout feature
to switch back to the branch from where I derivedfeature-wip
.git commit -sam 'my message'
it may needgit add .
before if untracked files exist.git push origin feature
always play safe and push your most recent commits to upstream.I hope that it helps someone :)
This can be live change.
Thanks man
It was for me... Cannot live without Oh-My-ZSH ;)
wow that is wonderful!
Will this work on a bash shell alias?
yes it will, just add both alias to your
~/.bashrc
or try Oh My ZSH and I bet with you that you will not come back to bash :)I can live without Oh My ZSH, but life wouldn't be the same ;)
When I have multiple tasks/projects going on, I usually build a mind map (after breaking down tasks into even smaller tasks) to track where I was previously.
I add checkboxes for ones I finished thus making it easy to go back and force between tasks/projects.
blurred as it's work-related and can't reveal
applies some CSI style bullsh*t to the image
So..., now I know your secrets....
Time to mindmap how to cover up my secrets π
what tool is that π²
Any MindMapping tool would do but I've been using MindMeister.
Cool! You are undoubtedly more disciplined in your work than I am... π€£
A down side is that a dev told he wouldn't want me as his manager lest I might micro-manage using the mind map π (I am not a manager btw)
Great post, I do a lot #2 (Test Failing) and too failing try #1 (Leave Notes).
But man, My stage area are always dirty. How a programming is working with it clean more than 5 minutes =)
Thanks for sharing.
Turned your article into audio to listen to it on my way to school. Dropping here a link in case it's useful to anyone else :)
I sometimes do an extended version of the git dirty tip, where I stop in the middle of writing a function. I often find it hardest to get going in the morning, and starting in the middle of a function/class/... in progress gives me a clear first thing to do.
It helps me to have a checkbox/todo list of really small parts of the task. The smaller, the better.
For big problems I actually find it beneficial to have a break, especially overnight. The flow can be sometimes dangerous as you don't stop to see the big picture and ask yourself "is this what should I be doing?"
Actually, context switching is a really expensive CPU operation π€.
Heh, fair point. The good news is CPU operations are cheap and plentiful! π
Love it. Here is my take on flow.
Use task focused workflow aided by mylyn in Eclipse
Call methods, which are not there, yet. Helps you structure your flow, keeps you at the problem at hand and if you leave and come back, it waits there for you to become implemented.