Why Do We Need Version Control?

Why Do We Need Version Control?

Simple analogies to understand why we need Version Control and how it is integral in development.

·

6 min read

I picked up coding while in School and kept at it for a few years before I took a break and went all in with Music Production. Internet was pricey and YouTube wasn't that popular then, so all my learnings were from school textbooks. Never did any books or teachers mention version control systems or the systematic way to approach the development of a project.

Whenever I had a stable version of a program and wanted to tinker with it, I'd first create a backup of the existing code so as not to break it.

Here's what I would do:

  • Create a copy of the folder

  • Append V1, V2, stable to the file name

  • Zip it and move it to my 'backups' folder

This was what I did for every major project that I built, even the final class project that we had to submit in class 12.

It was only when I got into my first job, almost 5 years later, that I got to know about version control, and boy, was I blown away! I could make backups, review previous states AND copy contents from one to another - all with a few basic commands that took hardly 5 seconds to type. I wasn't expecting this. I couldn't understand how I coded in the past without version control

monkey gets blown away when he discovers version control

.

I've seen a few tweets [1] [2] [3] since then about Git (which is one tool to implement version control) not being included in many college syllabuses, and that brings me here with this post. While Git is overwhelming and a topic for another day (I'll do it, I promise), this post stresses what version control is and why every developer needs to adopt the practice. And I'm going to do that by laying out mini real-world analogies.

Gaming

I loved GTA San Andreas while growing up. I could spend the whole day driving a car through the highways listening to the K Rose station. Back then, a lot of games didn't have the concept of auto-save. If one needed to save their progress they had to do it manually. Some games had that feature in the pause menu, while others, like San Andreas, made the process creative (and painful) by making players visit certain locations in order to make a save.

who needs a match to start a fire?

In GTA San Andreas, you'd lose all your weapons and some money if your character died or got arrested by the police.

Pop quiz: Who'd want to lose their jetpack, rocket launcher, or flamethrower? Answer: No one.

So It was recommended to make a save before trying out something risky, like a new challenging mission or an unknown sub-mission, or something crazy, like blowing up the whole neighborhood - which was usually the case with GTA games. Most games also allowed a number of save slots so that users could save their progress from different points in the game.

If you think about it, these saves are actually checkpoints that one can create as they make progress. Going to fight a big boss? create a checkpoint. Not sure where a certain path leads to? create a checkpoint. Want to risk having the cops swarm all over you while you have fun with a rocket launcher? create a checkpoint. You get the gist.

With these checkpoints in place, players can have peace of mind that their progress is safe and whatever may happen next in the game, they can always go back to the checkpoint. Now on to the next analogy.

Writing

Writers often have to work with multiple drafts before they get to their final, ready-to-share version of their work. Sometimes these drafts don't differ much, but there are times when two drafts are completely different from each other. To make matters more challenging, sometimes draft #5 would have bits from drafts #1 and #3.

Almost all online editors like Google Docs or Notion have a history feature where one can view a timeline of major changes that happened in a document. They can go back to a certain version and also copy content from one version to another.

There are also tools like Diffchecker and Copyleaks also make it possible to find out the exact differences, line-to-line, between two documents.

All these features and tools make handling different versions quite easy. Everything is in one place and different versions can be compared with a click of a button. No more scavenging through multiple manual backups to find that one killer line you came up with two days back. On to the final analogy.

Collaboration

Online collaboration tools (Google Docs and Notion are good examples here too) make it possible to view who made what changes. Therefore, from the timeline, it is possible to figure out who changed the heading, who added the second paragraph, and so on. In a highly-collaborative environment, it's a great feature to have. Or not, depending on whether you get promoted or fired depends on it. (Elon Musk has entered the chat)

Making Sense of Everything

After reading the analogies listed above, come back to the coding space and the process of creating checkpoints or backups as you make progress, and also working in a team of developers.

You never know when the code will break, things may not turn out as you expected, or you may have to drop something and go back to the most recent stable state. Creating manual backups as I did isn't a viable option here.

Wouldn't it be nice to easily create checkpoints as you make progress?

Wouldn't it be nice to be able to have different versions of your code and switch among them with ease?

In collaborative projects, wouldn't it be nice to have track of the changes made by each team member?

Version Control Systems has it all and more!

I agree that It could be a bit tricky and overwhelming to get a hang of when you start, but it is an essential and handy skill to have. It is also a must when you get into a job, so you might as well go through the pain of learning it now.

I'd recommend learning Git to implement version control. Although there are other tools in the market with few differences in how they work, Git is the more popular choice. I learned Git from Colt Steele's course on Udemy and can vouch for it.

To make the learning curve easy, you could first try using interactive tools like GitHub Desktop or GitKraken which have nice user interfaces instead of the dreaded command line terminal. You can switch to the terminal later, once you have a decent understanding of how things work.

So, go ahead and start learning Git, and witness the power of version control in all its glory.

Did you find this article valuable?

Support Abin John by becoming a sponsor. Any amount is appreciated!