Pages

Monday, November 11, 2013

Version Control Systems

Version Control Systems allow users to manage changes in programs stored in a computer system. Changes are usually identified by an incrementing number or letter code also known as revision number or revision.

One of the main features of version control system is branching. When you’re working on a feature which you are not sure is going to be in the next release, you can spawn a new branch and start working on it. After completing the feature, you can decide whether to merge it to the main line or to avoid it altogether. 


( image courtesy: FeatureBranch, by Martin Fowler )

Consider a scenario when 2 persons, Professor Plum and Reverend Green, work on their own feature branches as shown above. Both of them periodically pull from the main branch so as to avoid losing any updates. When Professor Plum finishes his feature, he’ll push it to the main line. After that, when Reverend Green pulls from the main line, he’ll get an entirely different version of the code. This results in a merge ambush when he tries to push it to the main line.


( image courtesy: FeatureBranch, by Martin Fowler )

The best practice to avoid this is to push the code to the main line regularly. This helps to achieve Continuous Integration. The longer you wait, the more painful it becomes.


( image courtesy: FeatureBranch, by Martin Fowler )

There are mainly two kinds of merges: textual merge and semantic merge. Textual merge refers to merging text from one source file to another. Semantic merge is tougher compared to textual merge, where we need to ensure that the feature that we’re going to merge should work with all other existing features. 

An alternative to using branches for making new features is a technique called Branch by Abstraction. This allows to make structural changes to the code-base incrementally without spawning another branch.

Another argument in favor of branching is Feature Toggle. Feature toggle helps to develop and test a feature on trunk. Imagine we are releasing into production every two weeks, but need to build a feature that's going to take several months to complete. Here we can create a configuration file to define a toggle for the unfinished feature. The feature will not be shown when the toggle is turned OFF. After completion, we can turn the toggle of that particular feature ON.

Distributed Version Control System

The distributed version control system uses a centralized repository, which allows a user to check in and check out. Here, the programmers are not aware of other people working in parallel, since they are isolated from one another. But there are some situations where it is handy to be aware of people around you. That’s why decentralized version control systems were introduced.

Decentralized Version Control System

A decentralised version control system, like distributed VCS, allows users to push and pull from a central repository. But here, every version of the repository that exists is a complete version of the repository. Each person has his own personal repository. A user can pull, not only from the central repository, but also from other users’ local repositories. In addition to that, commit and push can be performed within the local repository as well as on the central repository.

- a summary of the video, Version Control Systems, from Agile Engineering Practices, by Neal Ford

No comments:

Post a Comment