In the world of software development, the consequences of not having source control grow significantly as your software projects increase. Fortunately, starting to use source control is one of the simplest forms of technical debt that can be resolved. Imagine your computer crashes after you’ve invested hours into your project—this could lead to a significant loss of both time and money. Consider source control as insurance in case something goes wrong.

Source control isn’t just for companies; it should be considered essential for all your personal coding projects, especially if the project is more than just a throwaway. For companies, using source control should not be optional. It’s crucial to ensure that source control is mandatory for all scripts and software within the company. Too often, I’ve seen team members write a script or a small executable and never add it to the company’s central repository. Years later, things change. The code author may have left, the original computer might no longer be functional, or the company could have undergone changes in business processes or infrastructure. Changes are inevitable, and problems can happen. If source control is not employed, any number of mishaps could occur that would have been easily avoided with a few simple commands.

Check the case studies below to learn from others’ mistakes and avoid repeating them.

Case 1: The Developer Who Quit

A particular developer left a financial institution, but most of his code was in the central repository. However, one small project that he alone worked on was left on his computer. Whatever his plans were—whether he intended to improve it before adding it to source control or simply never planned to leave the company—the outcome was disastrous. He left the company, possibly forgetting this small system. The new developers had no exposure to this project, and he left no documentation. With this key task no longer working, these developers were tasked with recreating this service on a new platform and making the necessary modifications to get it working again.

The new developers had to reverse-engineer the application by decompiling the existing artifacts—a tedious process that involved significant overhead, including identifying the correct decompiler and getting IT approval to install it. What should have been a straightforward task turned into a complex operation, wasting valuable time and resources.

Had the original developer added this logic to source control, the new developers could have been added to the project as contributors, allowing them to analyze the code and make the necessary adjustments to get it working.

Case 2: The Snatched Laptop

A developer was asked to deliver a project and told the company he could do so in five months. Unfortunately, six months passed, and he needed to get it ready at least for a demo. Since he was the only developer on the project, he did not use source control. Feeling pressed for time, he continued working as usual. One evening, after spending time with friends, he returned to his car to find that his back window was broken and his laptop was missing.

From the company’s perspective, this was a significant loss in both time and money. They had invested in this project and now had to start from scratch. Not only was the initial investment lost, but other projects that depended on this developer or this project were also delayed.

Situations like this can lead to serious consequences for the developer, potentially including dismissal. Fortunately, the developer’s manager recognized the potential for learning from this mistake, which underscored the importance of source control.

Source control could have reduced the cost of the incident. Replacing the hardware wasn’t the issue; the time spent on development was the key area of loss. Had the developer used source control, he could have easily gotten back to his last code check-in point once he received a new machine, as the device would be swappable. Delays can be the difference between you and the competition getting the leg up as first to market. These incidents are not easily corrected once they have gone wrong, but they can be avoided altogether.

Case 3: The Oops Recovery

A developer was asked to correct a spelling error in a prompt visible to several users. Confident in his abilities, he performed a find-and-replace of the word “war” to “warn.” Unfortunately, he missed that the application also contained other words like “forward” (which became “forwarnd”) and “middleware” (which became “middlewarne”). Realizing the app could no longer be built and seeing hundreds of incorrect instances, he attempted to revert the changes by replacing “warn” back to “war.” This, as expected, caused even more issues, such as turning “warning” into “waring.”

Had the developer been using source control, he could have easily reverted to a previous, stable version of the code. Instead, he had to manually fix each instance, costing him and his team time and resources.

This scenario highlights the significant advantage of using source control. Should you need to revert to a previous code commit, this would be a breeze. Using a simple command, such as git revert [commitGuid], you could easily return to a previous snapshot.

Benefits of Source Control

With all the horror stories shared about not using source control, it’s worth highlighting the benefits as well.

Maintain a Single Source of Truth
Source control systems, such as Git, provide a unified repository for all code changes. This ensures that every team member works from the same codebase, reducing discrepancies and conflicts.

Facilitate Collaboration and Accountability
With source control, changes are meticulously tracked. Each commit records who made the change, what was altered, and why. This transparency fosters collaboration and accountability, essential for a harmonious and productive team.

Enable Safe Experimentation
Branching and merging allow developers to experiment freely without jeopardizing the main codebase. Features can be developed in isolation and integrated only when ready, maintaining stability in the primary environment.

Simplify Rollbacks and Recovery
In the face of bugs or errors, source control provides a safety net. Developers can easily revert to previous versions, minimizing downtime and mitigating the impact of mistakes.

Ensure Continuity and Preservation
Source control systems preserve the historical context of a project. As team members come and go, the repository retains the knowledge and decisions of the past, ensuring continuity and aiding future development.

Getting Started with Source Control

If you haven’t yet started using source control, here are some simple steps to get you started:

Step 1: Choose a Source Control System
You have options here, but if you are just getting started, I suggest using Git with GitHub (https://github.com/). It’s free to use, fully featured, and well supported.

Step 2: Set Up a Repository
Creating the home for your code is easy. You can follow along with GitHub’s documentation (https://docs.github.com/en/repositories/creating-and-managing-repositories/quickstart-for-repositories) or follow these steps:

  1. In the GitHub interface, click ‘New repository’.
  2. Add your repository name.
  3. Click ‘Create repository’.

For those with a legacy project that needs to be pushed to a repository for the first time:

  1. Ensure Git is installed on your machine (e.g., Git for Windows on PC).
  2. Navigate to your project directory using the terminal or command prompt.
  3. Initialize the repository with git init.
  4. Add your files with git add ..
  5. Commit the files with git commit -m "Initial commit".
  6. Add the remote repository with git remote add origin you@domain.com:/path/to/my_project.git.
  7. Push the changes with git push origin master.

Step 3: Commit Regularly
Ensure that you are committing for each feature or section of adjustment being made, and use meaningful comments so that you can track the work done in the commit history.

Step 4: Collaborate Using Branches
Branches allow you to develop features or fixes in isolation from the main codebase, enabling safer experimentation and easier integration. This section will be broken out in more detail in a future post.

Tools and Resources

Consider using tools like GitHub, GitLab, or Bitbucket. These platforms offer robust source control features and are widely used in the industry.

Conclusion

Don’t wait until you’ve experienced a costly mistake—start using source control now to protect your projects and ensure your work is secure. Whether you’re working solo or as part of a team, the peace of mind it offers is invaluable.

Leave a comment