Two qualities are desired whenever one is working on a project: safety and visibility. These qualities apply to everything from cooking a new recipe, building a high-rise apartment building, or developing and deploying a SaaS product. We want the safety of knowing that our actions will not have permanent, damaging effects and visibility into what is happening on the project at all times. This is where version control comes in.
Version control is a tool that offers software engineers safety in building and updating programs and visibility into code being modified by other developers.
What is Version Control
We have touched on some of the aspects version control offers, namely safety and visibility. However, we still need to define what version control is. Atlassian defines version control as the practice of tracking and managing changes to software code. This definition allows us to understand version control, or source control as some call it, as it labels this a practice, not a specific tool.
There are many approaches to version control and many tools that can be used to accomplish this. Version control could be as simple as duplicating code bases into time-marked directories on a server. This is an archaic approach, but it is an approach. A more common and often synonymous method for version control is distributed version control using tools like git.
The main benefits of implementing version control into your development process are the visibility of seeing when and who made what changes and being able to revert these changes if the action is counterproductive or unsafe. Version control solves our two project management desires: safety in visibility. Let us take a look at a few different types of version control.
Local Version Control
Local version control is the most basic version control you may practice as an individual developer. A local version control system is a local database located on your local computer, in which every file change is stored as a patch. For local version control, the database of patches is stored centrally on your machine.
This definition of version control raises an interesting point with its use of the word patch. When you change a file and want to store your change, you do not save the entire project or file. Instead, you only add the diff, or difference between two or more files. These two files would be the original and updated file, with the diff containing as few as two lines of code showing what changed.
Local version control is better than no version control but contains many issues. First, it is not very resilient. All changes and records of these changes are stored on your local machine. If your computer becomes unusable, all your progress, checks, and code will be lost forever.
The other issue is that local version control does not foster collaboration between developers. If others want to access your code changes, they need access to your machine to make the necessary updates. While local version control at least gives solo developers peace in that they are tracking changes, it is not a collaborative or resilient way to do version control.
Centralized Version Control
Centralized version control solves some of the collaboration issues inherent to local version control. Instead of storing all code patches for a program on the user’s computer, all code patches are stored on a remote server. Placing all code patches on a remote server allows more than one user to access and update the code. A well-known implementation of centralized version control is Microsoft Team Foundation Server.
There is a downside to centralized version control. Users can only retrieve the latest program version they are collaborating on. If the remote server were to be corrupted or destroyed, users could only work from whatever they have on their computers. While centralized version control solves the collaboration problem, it does not solve the resiliency issue.
Distributed Version Control
If you have worked on a modern software engineering team, you have probably used distributed version control. This version control is implemented using software like git and Bitbucket. This version control solves the collaboration issue by storing all the code on a remote repository, accessible by any authorized user. It also solves the resiliency issue with how users can access the collection of patches.
Instead of just returning the most recent patch for the program, distributed version control returns all of the patches made. This means any user working on a project will have the entire project’s history on their local computer. This helps prevent corruption or deletion of a project, as any user can push their local version of the program back to the server to act as a backup. Distributed version control truly is resilient and collaborative.
What are the Benefits of git?
We have discussed the two issues solved by version control, specifically, the distributed version control used by git. Let us dive deeper into how this software helps software engineers and engineering teams create efficient code. Version control is more than just a tool to keep the most up-to-date software in a centralized place. It is a collaboration tool that extends the abilities of programmers and teams.
Tools like git allow many developers to work on different features simultaneously. With branches, or versions of the main program with a specific purpose, you can work on a payment service while another developer builds an issue center feature.
Your version knows nothing about the issue center, but this does not matter. When you both want to add your software to the live app, you merge your branches to the main branch and resolve conflicts or areas where your code contrasts the main program. The ability for many developers to work on the same code simultaneously allows for explosive productivity as almost all tasks can be completed concurrently.
Along with building concurrent features, version control allows for more efficient code reviews and documentation of changes. Every time a developer wants to add their code to the main program, they must open a pull request to add their feature branch to the main branch. This creates a dedicated forum for discussing the proposed feature. Senior developers can offer feedback to fix or improve functionality, increase readability, and have code adhere to best practices.
The feature’s code shows up as a collection of diffs both the reviewers and any developers in the future can view. These diffs show the changes goal and the exact code that was changed. Being able to tell when things were changed and why is crucial for code audits and bug hunting if a feature has unintended effects later in its lifecycle.
Version control, like git, is crucial for documenting when and why features were added and who coded and reviewed the changes. These benefits allow for quick, efficient, and focused feature releases.
Looking to Extend Your Version Control Knowledge to Real Projects?
Version control is only one part of the toolkit needed to be a software developer. It is a means to safely build databases, and user interfaces with visibility into the actions of other developers on your project team. These skills are extended by version control, not separated from it. You should check out Thinkful’s Software Engineering Bootcamp if you are looking to learn how to develop software with popular industry languages and approaches. During this 5-month bootcamp, you will learn everything you need to know to build front-end and back-end parts of an app and implement version control to ensure consistency in your code!