Everyone who’s ever written code must’ve had days where they maintain different versions of their files. Whether its adding documentation to your code, rearranging the methods, adding or removing some classes or resources, we’ve maintained several versions. These versions are maintained by using naming conventions like
- GetCustomer_1.java
- GetCustomer_14Mar.java
- GetCustomer_Final.java
Naturally, you must’ve wished for an organized way of storing these versions to see progressive changes made to the code. Additionally, if one’s working in a team with multiple people working on different features, maintaining versions of all features quickly turns into a nightmare. This is just a tip of the breaking point in maintaining your code. In addition to these, let’s take a look at other common challenges faced by software teams.
Challenges in Code Management
Maintain copies of files based on date and time they were changed
While working on a feature to get customer details, one would name the file GetCustomer.java using different naming conventions to track its versions. Ex: Code completed at end of 15 Feb would be named GetCustomer_15Feb.java, followed by GetCustomer_16Feb.java and so on. And if you want to save the code at multiple checkpoints (temporary stable versions of code) in a day then the naming conventions for the file would become even more complicated.
Track changes made to files by different team-members
Suppose you’re working in a team of 6 members writing tests for a particular feature. It’s imperative to ensure that there’s no duplicate or ambiguous code. Also, team-members should reuse code already developed by other team-members. And also ensure that everyone uses the latest version of code developed by others. This would be an excruciating task for a team consisting of multiple people. Especially if they’re working in different locations.
Trace the file’s history to find the version of code which introduced the bug
Code undergoes regular changes either during development or maintenance phases. It’s quite possible to inadvertently change something that causes the code to misbehave and not work as expected. In such situations, it’d be helpful to view the timeline of changes in code to pinpoint the exact cause of bug.
Maintain back-up of your files
In a unfortunate situation of hard-disk being corrupted or being subject to some malicious virus, working copy of your code is highly vulnerable. As a result, it’s highly likely to lose all of your work in absence of proper backup of your code.
Comment out blocks of code to disable a functionality without deleting it
When the code is still in development, you might write a small sample piece of code to see how a particular method behaves. Irrespective of whether this experimental block of code tests your feature or not, you’d like to retain it for reference. It’s not feasible to maintain multiple versions of files by commenting and un-commenting different blocks of code.
Under light of all these issues, there has to be a better way of maintaining the versions. Hail, Version Control Systems!
What is Version Control System?
You can think of a Version Control System (aka: VCS) as a kind of database. It lets you save a snapshot of the complete project at any point of time. Every change made to the project files is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change. Later when it is required to take a look at an older snapshot/version, VCS shows how exactly it differed from the previous one.
Version Control Systems (VCS) are tools that help teams manage and track changes in code over time.
With reference to the image above, on 24 Feb, 17 your project has a new file added to it. This file could be a source-code file, a properties file, an image or any other type of file. Once your project is tracked by VCS, any addition, edit or deletion of files from your project will be automatically detected and recorded by it. In short, every time a change is made to the project, VCS creates and stores a snapshot in form of versions.
Note: Snapshot is the entire state of your project at a given point of time.
Version Control System also popularly know as:
- Revision Control System
- Configuration Management System
- Source Control Management System
Though different names, these tools simply aid in maintaining tracking changes in your project over time. Consequently teams can focus on business logic and improve its productivity. So VCS are basically a convention of modern software teams to maturely handle code as part of their professional practices.
Next let’s skim through the primary features of a VCS and how they help in overcoming the challenges listed above:
Features of VCS
- Maintain independent branches of code for team-members to track their respective changes
- Ease of comparison of code across different branches
- Merging of code from several branches of multiple team-members
- Convenience of tracing changes in code to find the version that introduced a bug
- Annotate changes with name of author and message in a particular version of code. This helps to easily identify the intent of change
- Simple comparison across versions to help resolve conflicts in code during merging
- Revert changes made to code to any state from its history.
These striking features demonstrate the great flexibility provided by VCS in terms of code-management. Consequently, software teams have intricately integrated VCS in their daily workflow. Don’t fret if lot of terms in this list of features don’t make sense right now. Detailed explanation of these terms will follow in upcoming tutorials.As part of journey towards becoming an Automation Test Engineer dealing with lot of code, it’s imperative to learn about VCS.
Git is a widely popular Version Control System developed by Linus Torvalds. More specifically, Git is a Distributed VCS.
Top Version Control Systems
There are many Version Control Systems are available in market, but few top VCS are:
- GIT
- CVS
- SVN
- Assembla
- Mercurial
- Bazaar
0 comments:
Post a Comment