Why You Should Use Source Control

Published: {ts '2010-11-12 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/why-you-should-use-source-control/

If there was one piece of advise I would give to any developer starting out, it would be to use source control. I dont care what type you use CVS, Subversion, GIT, "Visual Sourcesafe" etc, just use it.

Why is Source Control Important

Time and again I encounter environments where source control consists of a portable hard-drive, or a folder on a desktop where a copy (copies) of a complete application is stored. Often this copy is either weeks old or badly named. In particular I remember one time I needed to restore an applications code to its previous state 24 hours before. On looking in the backups folder I found that yes there was a dated copy of the application, there were in fact several. I dont remember the exact naming conventions but it went something like this.

Further I has seen many examples of as little as 2 developers overwriting weeks of each others work by accident. In particular the combination of Dreamweavers ftp, a remote development server and an application framework which uses includes (eg Fusebox 3) is notorious for causing situations where weeks of work are overwritten in seconds.

The Benefits

So what benefits does source control give you? Well in answering this I am going to limit my answer to subversion which I use, although most source control systems offer the same net benefits.

Overwrite Prevention

It is impossible to accidentally overwrite someone else's work. If you are commiting code that conflicts with another developers recent code you get warned and given the option to review the conflicting code and resolve it.

Change Tracking

With source control you can see all the changes made to a code file between any other version with a line by line comparison of changes. (appropriate ide plugins required eg subclipse). Further you can see who changed what, when and why (provided the developer provides adequit comments).

Featureset/Edition Branching

If you have a need to split an application into different editions its a simple matter of creating a code branch. The flexibility this provides for maintaining editions or developing new features cannot be underestimated.

The Arguments Against Source Control

I keep hearing the same arguments against using source control. I would like to briefly discuss the most common ones.

Argument 1: Its a hassle to setup

Yes source control does take a little work to setup especially if you are not familiar with how its works. However if you compare the time required setup a source control to the time lost when trying to track recent changes or restore application code that has been overwritten by accident then it quickly becomes obvious that the initial time investment in configuring it will be saved time and again in the future.

If you dont have the skills or the time required to setup your own source control service then you can also rent a hosted solution instead. This takes away the hassle of trying to do it yourself (or getting your IT department to ok the service and install it this side of the next ice age).

Myself I use a company named Codesion who have recently been aquired by CollabNet the founder and corporate sponsors of the Subversion project. They offer a lot of good services at a reasonable price. Yes its will cost a bit more than doing it yourself but its quick and easy.

Argument 2: Its difficult to use

Every source control system does have a learning curve to using it and its own quirks. I myself have had a few problems with subversion when I was first learning it. However the benefits have outweighed the problems so much that now I dont even remember what the problems were.

A part of this argument that I have heard is that "our IDE doesnt work with source control". I can only describe this argument as a total cop out. Every good IDE has some source control function. Even Dreamweaver an IDE which I personally hate has had source control functions built in since CS3. If you really do use an IDE that does not have source control support then my advise is get a real IDE. I use eclipse which is 100% free and is probably the most customizable IDE available.

Argument 3: Its easier to just work on the production code

This argument is very common for developers of web based applications and more than any other argument I hear, this one makes me see red!

Yes it does take time and effort to setup a development environment and configure it with source control etc. The simple fact of the matter though is this, if you think its ok to develop on a live production system then you are not someone I would want working on my systems.

Its one thing to say that you cannot build a development system because of company politics or lack of resources or time, but if you have the resources and no obstacles to contend with then its simply not excusable to develop on a live production system.

On my next article on source control I will outline two basic source control configurations.