Читать книгу Beginning Programming All-in-One For Dummies - Wallace Wang - Страница 106

Managing Source Code

Оглавление

In the old days, programs were often created by an individual or small teams of people who worked in the same room. If they needed to talk to each other or share code, they could simply copy files from one computer to another.

However, as programs have gotten much larger and more complicated, it has become common for multiple teams to work on a single program. Even worse, these separate teams may be located in completely different parts of the world and in different time zones. How can multiple teams work on the same program simultaneously? The answer is through version control or source management.

The problem is that at any given time, only one person can work on a program. Because most large programs are divided into multiple files, all files get stored in a central repository so there’s only one copy of a program.

When someone needs to edit the program, they can check out the file they need. When they check out the file, the repository stops anyone else from checking out that same file. That way two or more people don’t try to modify separate copies of the same file and then wind up not knowing which version of the file to use in the future.

When someone gets done editing a file, they can return it back to the repository for someone else to check out. Although there’s only one copy of a file that others can check out, the repository will often save the previous versions of each file. That way, if a modified version of a file causes catastrophic errors, it’s easy to revert back to the previous version of that same file.

Sometimes two or more programmers will be allowed to check out the same file, and when they’re done, the version control software can merge the two different file versions into a single, new version. However, merging changes made in separate copies of a file can cause problems if the changes in one file interfere with the changes in another file.

For example, suppose one programmer deletes a function in a file because it causes problems, but a second programmer writes new code that relies on that function. Merging the two changed files will then be tricky because if the deleted function is added or kept out of the file, it risks causing problems either way.

Whether a program is small or massive, it can benefit from version control management. Version control makes sure you always work with the latest approved versions of a file and that you’ll always have backup copies to fall back on in case you make a mistake.

If you work alone, version control management can keep you from losing crucial data. If you work in teams, version control management can improve everyone’s efficiency by making it easy to work on multiple files simultaneously.

Beginning Programming All-in-One For Dummies

Подняться наверх