Programmer’s context switch
Say you are working on one project when someone calls you or sends you a mail asking you to look into another project, either a bug in one of your old projects or problem in his. Although programmers don’t like interruptions, this is a case where you have to do that context switch and return to your project afterwards. So, how to do this efficiently?
I don’t know a silver bullet like solution but this summer I’ve learned some things and I’ve decided to share them. Maybe, in the comments or elsewhere, better solutions will appear.
First step towards rapid context switching is to use a CMS. Preferably one which allows easy branch creation and doesn’t allow you to push conflicting commits upstream. Git or darcs are good tools for example, but there are others which I haven’t had the chance to work with. This helps because you always keep you changes on a different branch and merge them when the problem is solved. Thus, you cannot forget what were you doing or forget to delete a wrong written line that you observed was not well placed when that call happened.
Using the repository helps also if the bug is totally unrelated to your current task. For example, during this summer I had to work on something when a bug report arrived with the following content:
mihai@Asgard:~/naaya$ bin/nynose -h
Preparing Zope environment ...
Error: No 'address' settings found within the 'http-server' or
For help, use bin/nynose -h
I did a new branch, worked on it and submitted back, all without affecting my current task situation, without polluting the environment.
The second part of the solution involves judiocious use of
popd commands. Along with their arguments, this can help when changing between multiple subprojects directories and pulling the changes from the repository before doing a build command for the entire project, for a small example. Yet, this also helps when that call makes you work on a totally unrelated project and you don’t want to open a new tab or window just to clutter your workspace (as a matter of fact, this summer I’ve used only one firefox and one terminator instance for all the task I was involved into).
And, the last component of my solution is to use the
CDPATH shell variable such that you only have to type
pushd new_project instead of the entire path to that project. This is a tip taken from Răzvan Deaconescu
What tips do you have to make context switching faster?
Article written using HaCoTeB (testing version 0.2)