The other night I had one of those “senior developer’s moments”. After checking some files into SourceSafe from Visual Studio I noticed a red checkmark next to the project file. I hadn’t touched the project file for days, but thinking that I had inadvertently checked it out I right-clicked on it and selected “Undo checkout”, then clicked OK on the dialog warning me that I would lose my changes.I then scrolled down to the file that I had been working on all day, and was startled to notice that it wasn’t checked out. My heart sunk, then raced, as I scrolled madly through the code looking for some assurance that I hadn’t done what I was afraid that I’d one. So such luck. Thanks to a misplaced checkmark, Visual Studio’s hierarchical source file management and my own inattention, I had just thrown away a day’s worth of changes to this file.
I don’t suppose SourceSafe puts the file it overwrites in the Recycle Bin? Nope. I rather hopelessly ran UnDelete Plus — this is a fast, simple and, for the present, free file recovery tool, but it wouldn’t be able to retrieve the file if SourceSafe had just overwritten it. Naturally, it had. I frantically searched Google for “Sourcesafe undo delete”, but those who had previously made the same dumb move weren’t admitting it to the world.
That’s when it hit me: I did have a backup, of sorts. One of my favourite open source software gadgets is an expanded clipboard named Ditto. This loyal sidekick silently keeps track of everything that you’ve put in the Windows clipboard for days – by default, the last 500 items.
Almost any coder will accumulate a lot of stuff this way. Any time you cut a piece of code to move it to another class, or reposition it within the class, or even just to get rid of it, Ditto saves a copy for you.
Of course, this sort of snapshot tool is really handy for things other than coding too. In fact, once you get used to the fact that Ditto is there, you routinely make a copy of text before changing it even if you don’t need it in the clipboard, just in case. Ditto allows you to find data either chronologically or by searching for a string, so it’s usually quite easy to find what I want later.
For things like screenshots I use a commercial tool called SnagIt, which can be configured to automatically store screenshots to its Catalog. SnagIt also has a cool feature that allows you to extract the text from a screenshot. When I come across a bug, invariably while working on something more urgent, I just take some snapshots using Ditto and SnagIt then carry on with the job at hand. This ensure that when I later get around to reporting the bug, I have more to offer than a vague memory.
So, with the help of Ditto I was able to piece together most of the code that I had deleted, an exercise which set me back by only an hour rather than a full day. For me, Ditto was a tool that I didn’t think I needed until I gave it a try — now, I’d hate to have to get by without it. If the phrase “clipboard extension” makes you think of the clumsy and intrusive feature that Microsoft added to Office then you have the wrong idea. Ditto is more like Google Desktop for all the stuff that you didn’t save to a file, but now wish you had.