Sign up to be kept up-to-date with news and offers, 100% spam free!!

How can you improve your coding quality with a versioning Tool?

A versioning tool can be used for purposes other than saving different versions of your files.
One of the key feature, is to make code review easier.

Let’s start by explaining what code review is:
Code review entails looking at source code with the intention of finding mistakes to improve overall software quality.
All you do is read it and try to understand it, like you would read a math book.

Most of the time, by doing this simple thing, you will discover bugs! Fixing these bug will be far easier than using the usual process (no need for testing and tracing into the code to find these bugs.)

– How a versioning system can help you ?
It stores different versions of a source code, so before sending your new version (submit/commit) you can display which lines in the source code have changed!
There are usually 3 “human” configurations:
A senior programmer and a junior programmer: Before sending code produced by a junior programmer into the main code base, an experienced programmer should carry out a code review.
If modifications are good, it’s submit/commit. If code quality is not good enough, the junior programmer will continue working with the help of the senior.

Two senior programmers: Even a senior programmer can create a bug… Even a senior programmer can produce obscure code. A scan over from another programmer can help to give code quality another perspective.
It’s sometimes hard for the ego (programmer’s egos are usually verrryy big), but it will certainly progress you further.

One programmer: You are alone…Sniff. Or other programmers simply don’t have time to review your code (They are too busy.) Carrying out your own code review is a must!
It should be done before every commit/submit. It should even be done before another programmer reviews your code.
It helps you detect bugs and improve quality (simplifications etc..) but it also helps you memorize your own code!
If your source code is in your head, you will be able to fix bugs more quickly, find solutions faster. I myself find bugfixes on my way home, in the subway! And the fix is usually something small like adding a ‘+’ or an uninitialized variable.

A versioning tool is a must for every developement process. It can save you time and greatly improve software quality.

 

 

Which versioning tool is the best ?

For people who don’t know what a versioning System is:

The basic functionality of a versioning system is to help you keep several versions of the same file.

For example, you’ve code something. You ask the versioning system to save your file at this version.
You continue working, but what you’ve done destroy everything (it doesn’t compile anymore, your data is corrupted). You can get back to your previous working version.

There is more advanced functionality:
Save your work: When you send your file to the versioning system, your work is saved on the server.
Compare 2 versions of a file: which modifications each programmer did.
Keep History of every Modification.
Revert changes: You made something that don’t work, you cancel your modification.
Merge two files: If two programmers work on the same file, modifications of each programmer can be merge in the same file!
Share your work: You can get every files saved on the versioning server. Every member of the project can get new version send by other members. This facilitate distant work.

This kind of tool is essential in any developement!
It can be used to manage coding file, but it’s also useful with all game data ( sound graphical etc…).
The only dissimilarity between managing code file and managing game data file is that game data file usually can’t be merge.

I’ve used several system. They all have pros and cons.
I will compare 3 versioning system based on my own experience : SVN, perforce, mercurial.

SVN : SVN is an enhanced version of CVS. You use it with command line, but hopefully there is a GUI software for it called tortoise.

Pro:
– It’s Free.
– It’s very stable and used by most developer.
– It’s simple : Complete windows shell integration. You just have to right click on a file in windows explorer to access  all functionalities.

Cons:
– No realtime feedback. SVN use a “client” philosophie. For instance if another person change a file, you don’t know it until you manually update this file and make a request to the server.
– Slow on big database ( check every file )

Perforce: Big company like Ubisoft, Electronic Arts, Crytek or Google use it. It’s not  an opensource/GPL tool.

Pro:
– Very fast on big data base. It is maybe the only viable solution when you have to manage a lot of data ( more than 20Go ). And that’s probably the main reason big company use it.
– Good support ( support Answers in less than 2 days).
– Realtime feedback.

Cons:
– Very expensive. 900$ per user with the support ! ( 2011 )
– Bad interface ( not integrate in windows, every operation is complicate ).
– Not risk free. Every modification made outside Perforce tool can be canceled when you do a simple update ! Perfoce don’t check if files are modified locally.
– Missing functionality: No “Blame” for example. Also there is no simple way to do a code review, even with new features introduce in the recent version of perforce.
With svn you just need to send a patch. With mercurial it’s even more simple because you just need to go to the other developer branch.

Mercurial: It’s a student project, turn out to be pretty good.

Pro:
– Free
– You don’t need a server.
– Very good with Branch. Developer can work on his branch and merge his modification on the main branch when he want. You can work and save your change without taking the risk of breaking the main base. Branch are possible with SVN and perforce but it’s always a nightmare to create them ( it copy every files…) and merge them with the main branch.
– Every person can have his own server!
– Merging is a pleasure with mercurial.

Cons:
– Slow on big data base. Like svn it check every file on your hard drive to see which one has changed.
– Tortoise HG the GUI for mercurial is not polish like Tortoise SVN.
– Biggest file handle is 2GB ( we have several file on our project bigger than 2GB! )

My advice:
– For your first time: SVN. It’s simple to use, efficient, and concepts are easy to understand. User interface is also more finished than Mercurial.
– If you have a big team with lot of data: Perforce. It’s the fastest tool, but the user interface is really bad. Less feature than SVN and User interface is lot more complicate!
Good professional support.
– For small project ( less than 20 people) : Mercurial. It’s still young but its potential is greater than perforce and SVN.

For you information Goole use Perforce and Mercurial simultaneously. Perforce to manage the big code database, and mercurial to work on each project.

For our Iphone game Projects, I use SVN with the webhost Dreamhost. It seems to be the cheapest solution on the web for SVN ( about 10$ a month with unlimited storage, webhost,PHP, sql etc.. ). Their SVN Server aren’t the fastest one, but they are fast enough to work in good condition.

There is other Tool I didn’t mentions: Microsoft Visual SourceSafe and Git. I’ve not used them enough to give a good opinion about them.

 

I hope I’ve helped you to choose the right solution for you.
Any comments are welcome.