We read the basics and importance of the SCM process in our last article – you can check that out here: Software Configuration Management Guide.
In this post, we will start with the most important aspect of SCM – VCS i.e. Version Control Systems.
Let’s get started.
What is Version Control System?
VCS is the root of the tree named SCM – without Version controlling, the Software configuration management process cannot be assumed.
Version control is also known as Revision control a.k.a. source control, is a process to manage a collection of program code and changes that provide you with many capabilities, such as:
- Maintain multiple versions of code
- An ability to go back to any previous version.
- Developers can work in parallel.
- Audit traceability with clear picture on whom, which when, where and what are the changes.
- Synchronize the code.
- Copy/Merge/Undo the changes.
- Find out the difference between versions.
- Provides full backup without occupying much space.
- Review the history of the change.
- Capable for both small and large scale projects.
- Ability to share and work on the code across the globe.
In simpler words, Version Control System allows you to manage and keep track of all your source code, along with the evidence that all your changes are being stored in a repository.
Importance of Version Control Systems
Let’s take an example of an organisation with a project team of five developers.
Two of them are sat in one location and the other three are in a different location. They got a project and started developing the code, they come across the following situations when they were working on the project:
Each developer is working on one module at a time whereas others were waiting for him to complete his tasks so that they can start working on that [Time Consuming Process and inability to work in parallel].
Whenever they complete their work and decide to deploy the code, they were taking a full backup of the project and one day they couldn’t do it because the disk was full [Disc Space issue].
One day one of them deleted one module which they couldn’t bring back and had to rework on the same module [Inability to revert the changes and get the old code back]
They were unable to find out who has done what changes and when the changes were made [Inability to view the history and lack of traceability]
They couldn’t do any experiment for the new feature without interfering with other’s work [Inadequate programming practice]
They need to send the code via email as they were seated at different locations [Incapability of working across the globe and hence jeopardizing collaboation]
Here comes the need for a Version Control System which can help you to achieve all the above incapabilities along with many more other features.
A version control system always ensures that all the previous versions of all your code can be retrieved later on and all changes to the code can be traced over time.
It will help you to find out what changes were made to which file, when, why and by whom.
It also explains that what a file looked like on a specific date or at a specific release along with the ability to find the differences between any two versions of a file.
A version control system provides the ability to work in parallel without snooping the other’s work and that too across the globe. [Click to enlarge image]
Types of Version Control Systems
There are 2 types of Version Control Systems – namely Centralized and Distributed.
Centralized Version Control
The concept of a centralized system is that it works on a Client-Server relationship. The repository is located in one place and provides access to many clients.
A snapshot of how a Centralized Version Control System works.
Distributed Version Control
On the contrary, in Distributed System, every user has a local copy of the repository in addition to the central repo on the server-side.
Below is how a Distributed Version Control System works.
You can direct your browser to this link to check out the difference between Centralized Version Control and Distributed Version Control.
Version Control Systems: Best Practices
- Make sure that you put all your code, documents, configuration files, etc under version control system.
- Update your working copy frequently to incorporate others’ changes in your local working copy and to get the latest.
- Test the code comprehensively in your local before committing to make sure it’s really completed and has no side effects.
- Commit often, self-contained changes regularly but don’t commit half work done which may break any functionality.
- Write a descriptive commit message so that any other member can easily understand what made you to commit this change and how its different from previous commit.
- Always remember that the tools are line-based and make sure you don’t change the file format while updating your code.
- Use a common project structure and naming convention to avoid any confusion for others
- Setting up change notifications to send out an e-mail whenever any commit is made.
- Always do regular backups of your repository or schedule a nightly backup for all the repositories.
Benefits of Version Control Systems
Version Control System works as a database of all your code and makes revisions instead of duplicating the files which helps you to save a lot of disk space
It keeps all the history of all the files which gives you full traceability and audibility of the change on what changes were made to which file, when, why and by whom.
It provides an ability to revert back to the last revision or any previous stage as per requirement.
It prevents the risk of losing functioning code or breaking test scripts by overwriting files as you can always take out the last working code at any point in time.
Helps you to identify the difference in any set of files, compare the revisions and merge the changes as per requirement.
It provides you with the facility to have entirely independent code versions if you prefer to keep different development code, once you are ready, you can merge the files to create a final working version.
It provides an ability to work as a distributed team with full collaboration across the globe and saves time and additional efforts for everyone. There is no need to wait for others to complete the work.
Once you implement Version Control Systems in your organization you will definitely feel that you made your life easier 🙂
I hope you liked this article and you now have a fair idea about Version Control Systems, its benefits and various best practices.
In the coming articles, I am going to cover more about version control.
Till then, stay tuned!