Backup your code! Tips for avoiding catastrophe.

There have been a number of times in the past where I've lost projects, code, and precious time to power-outages, computer crashes, stupid decisions, and other annoying miscellaneous phenomena. I'll provide some tips so you can have peace of mind in knowing that you always have a recent version of your code saved in the event that any of these things happen.

The first thing to get in the habit of is to always save your code. I almost always hit CTRL+S every time I enter a new line of code. If you're coding hours between saves then you need to get into the habit of saving more frequently. Even an hour's worth of coding is a bummer to lose.

If you're making changes to your code that you don't want to save, say if you're trying something new or debugging, backup your project folder so you can effortlessly go back to where you left off after wards, rather than manually undoing all your code changes.

Always make backups of your project. The more frequently the better. I'm pretty lazy when it comes to this, but when I reach a milestone or make some excellent progress, I'll copy my project folder, zip it, and save a copy on my hard-drive, on my web-server, and I'll email a copy to myself. You don't want your backups all in one place. Make sure that you have at least two places to store your backups, so in case one place dies, you still have your backups at another location.

Backup your project before going off on a tangent. If you want to try something that diverts your project in a different direction, like recoding the AI or experimenting with different physics, make sure you backup your project before proceeding. I've made the mistake of not doing this. I either didn't like the new feature or it made my project unstable. And I found it very difficult to revert back to where I was, or I just gave up on the project.

For example, I wanted to recode the enemy system for a game I was working on in the past. The enemy data was stored in an array, and I wanted to recode it all as a linked-list, to make it easy and efficient to add and delete enemies. After I did this, I had a whole slug of new bugs and I just wanted to go back to where I was before. Unfortunately, the last backup I had was of a very old version that I didn't want to go back to.

Last tip, but very important: make sure your backups can compile! It's no fun going back to a project that won't run. Maybe back when you made the backup you knew, but now you're stumped and have to spend hours figuring out how to get the damn thing to run. This also includes stripping out all the absolute paths in your code and replacing them with relative paths, so your project will run when it's in a different location. You want to do this work before you make the backup, when you know where everything is, rather than spending time after you've forgotten most of your code.

I've learned these lessons the hard way. Learn from my mistakes and hopefully your projects will be successful, or at least completed for that matter.

2 comments:

  1. hey man - u still go on msn or irc? If you do - I hang out on freenode (#thehideout and a few other places) or on msn (nexinarus@gmail.com).

    ReplyDelete
  2. I still use MSN, but I changed my account. Don't worry though, I'll add you.

    ReplyDelete