Answer on @Quora by @khashmeshab to What is a coder's worst nightmare?
Answer by Masoud Gheysari M:
This is not my nightmare, but something that happened to me in real life. When you read this, it will become YOUR nightmare from now on!
- I'm a senior software developer working at a large software company,
- We write in PHP and use Zend IDE 4.0,
- The Ctrl key on my keyboard is kind of broken, sometimes it doesn't respond when pressed,
- I'm working on a large enterprise web application for a government project with an approaching deadline.
I got to work in the morning, turned on my computer and started working on a PHP file. I wrote thousands of lines of code, solved many unsolvable problems, and fixed many hard bugs. I had a super productive day. At the end of the day, I asked my boss and my project manager to see the result of my work. I, overflowed by Serotonin resulted from a good work day, presented everything on my computer while they were standing behind me and they got happy.
After they gave me the "nice job" look, I decided to save the file for the last time, commit the changes to our Visual SourceSafe server, and leave work. These all happened in 3 seconds:
- I tried to press Ctrl+S to save the file. But I mistakenly pressed Ctrl+A (select all) instead. The whole text of my file got selected.
- Once again I tried to press Ctrl+S. But since my Ctrl was semi-broken, this time I didn't press it hard enough and it didn't work. So, my whole thousands of lines of code got erased and got replaced by a single "s".
- I panicked. I pressed Ctrl+S once again, and this time it worked, and saved the new file contents (a single byte "s").
These all happened in 3 seconds. I tried to use Ctrl+Z to undo the last change. But as you may know, in early versions of Zend IDE, the undo function was implemented very badly. So it got me to the morning, when I started my work on the file.
There was no backup or SCM revision. I lost everything. I just wanted to cry, and cry, and cry… The good thing was that my boss and the project manager saw the completed work and witnessed the procedure of destroying my own work. I stood there for a few minutes shocked, and then I left work sad and depressed.
Needless to say, I got a new keyboard the next day! But I learned my lesson for life. Nowadays I always backup my work. I install Ditto (a very good open source clipboard manager program for Windows) and periodically "Ctrl+A, Ctrl+C" (copy all) my work into the clipboard just in case. I always use source control software (Git) and commit regularly.
Edit: some readers have suggested some ideas to prevent this problem, such as using Git, checkout in a Dropbox folder, use a better IDE, replacing my keyboard, etc. And they called me ignorant and unprofessional. So this is my answer:
- It was an unfortunate accident. It could happened even to Bill Gates, Steve Jobs, Linus Torvalds, Mark Zackerburg, etc. Even with the best keyboards, IDEs, source control software, etc. I mean if it's going to happen, then it's going to happen.
- This story belongs to 8-10 years ago. So no Git or Dropbox or advanced IDEs with features like auto backup, revisions, commits, etc. We even haven't had a stable internet connection inside the company. My monitor as a senior software developer was a 17" CRT monitor for God's sake!
- Zend IDE was the official IDE for the company. Visual SourceSafe was the official source control and Windows was the official OS. While personally I prefer using Eclipse (and Git and FreeBSD/Linux), I had no other choice than following the rules. Fortunately Zend IDE 5.0 was based on Eclipse.
- Replacing the keyboard is hard for me. I think more professional programmers understand me. Even a slight change in the keys placement, size, smoothness, … can highly reduce your typing performance and increase your use of backspace. So when my keyboard gets broken, I need to spend a lot of time to look for a good replacement.
- It's true that keyboards has two Ctrl keys and I could also use the Edit menu. But when you get used some patterns, you would use them without thinking. Also to press Ctrl+S, you use the nearest and easiest Ctrl key to S, in this case the left Ctrl. I don't think anybody use the right Ctrl or the Edit menu ever!
- The file I was working on that day was part of a huge proprietary PHP framework. The framework structure dictated how the files should be arranged. From time to time, we had no other way than putting thousands of lines of code in a single file.
- I'm a programmer for 20 years. I don't say that I'm too professional and nobody should ask my ways. But I probably have enough experience to know what I'm doing and is this a correct way to do something or not. This was an "accident". It had to happen.
Also: Thanks for the upvotes everybody. This is my highest voted answer to date. Keep upvoting and as soon at it gets to 1K, I'd edit this answer and add another story which I'm pretty sure you'd once again enjoy my bad luck! ;-) I'm pretty unlucky guy, so I can write a new story for each 1K upvotes!