PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Source Code Management

I thought I would post about source code management (or Source Control). After many years of developing software without it, I finally decided that I needed some source code management. Over the course of several large projects I had made sweeping changes that caused new problems and bugs. The ability to contrast the old versions of the source prior to all my changes would have helped isolate the problem.

I had also played the #ifdef game far too long - making new changes optional or at least more obvious by wrapping them in conditional precompiler directives.

I'm certainly no expert in this area, but Source Code management basically does 3 things for us:


  • Allows multiple developers to work on the same source base at once by "checking out" and "checking in" specific source files. Only files that have been "checked out" can be modified (if so configured).

  • Maintains versioning containing all changes made to the source code from "check in" to "check in". This allows you to step back to previous versions of the source, or use a program like WinDiff to compare.

  • Integrates directly into the VC++ or eVC++ IDE GUI so that all this can be done automatically within your normal development environment with the smallest of user intervention.

There are several products out there that do what I require. Microsoft's rendition is Visual Source Safe. However the product I settled on is Perforce. Why? Well, because it's completely free (for up to two users). :) I have been using it for a couple months now, and have been very pleased with it.

Initial setup (not per project, but initial one-time setup of Perforce) can seem a bit daunting at first. There is a service that runs on a server (or just the local workstation for small developers like me) that handles all the actual transactions. There is a standalone GUI for managing various projects. Finally there is the integrated plugin for Visual Studio that does all the work from within your usual development environments (VC++ / eVC++). Basically you have to create a user and a changelist. Once that is done everything else can be done from within eVC++, and you never even need to run the GUI management program.

Once Perforce is installed, and the service is running (as it should be all the time), you're set to do the basic 2 things required on a regular basis.


  • First is adding files to Source Control. Anytime you create a new file in eVC++ (Project->Add to Project->New) a box will automatically appear and ask you if you want to add the file to the source control system. Hit okay and that's that. For existing projects you can simply go to the FileView tab, Right Click on the name of the Project, and hit Add to Source Control.

  • Second is the day-to-day checking in and checking out of the source files. For single developers this is really easy. Just check things in whenever you want to take a "snapshot" of all your source at its current point. That is done by right-clicking on the Source Files folder and selecting "Check In". It's that easy. For multiple users you would have some rules in place, such as only checking out individual files at a time (as opposed to all of them in a project), and checking files in as soon as your done with them. As a single developer I simply leave them all checked out all the time. Even if you completely exit out of eVC your source files will still be checked out if you didn’t check them back in.

I'll stop at that, and perhaps others can post questions or experiences they have with source control.

Simply put, if you are a serious developer, which I know most of you are, you should be using source code management. There will be some point where you will need it (to restore damaged source files, step back to older working versions, etc), and it is like insurance on your investment, protecting your source code. What I explained above isn't really a guide on how to use source management, as much as to (hopefully) illustrate how little work or complexity is involved on a day-to-day basis, and to show that high-quality tools are available for free.

Dan East
Most experts and professionals agree that source control is an absolute necessity. Only amateurs seem to insist on doing without it.

Professionally, on teams of about a dozen developers, with several projects and "branches," I've used CVS (open-source), Visual SourceSafe (MS), and another older one the name of which escapes me.

They all have their quirks, though all are relatively inexpensive. More robust solutions typically cost more $$$.

That said, as a single developer working from home, I stopped using source control. But understand my situation... I don't have other developers to worry about conflicting edits. I make sure I archive my source tree after every day of work, and periodically move these archives to another machine about once a week. And I keep a detailed development log so I know what I've done each portion of each day.

I consider that to be adequate source control for me in my situation at this time, and I am comforted in the knowledge that I can get CVS running on my Linux machine whenever I need something more robust.

But I must stress that you (the reader) need to find a solution that meets your needs, and doing nothing is inadequate, and doing everything manually may be inefficient. If you've never tried source control, do it this week. Otherwise, you won't know whether it is right for you. I know what benefits source control gives me, so I know exactly when to move my projects to source control (probably in about six months).

BTW, some people use source control for everything: their documents, their web site, their Unix home directory, you name it.
mlepage wrote:
I make sure I archive my source tree after every day of work, and periodically move these archives to another machine about once a week. And I keep a detailed development log so I know what I've done each portion of each day.


Now I'm nowhere near that disciplined in those areas. I cannot count on manually backing up and making notes on a daily bases. It is further complicated by my having 3 or 4 projects going at a time.

I make backups to take off-site every couple weeks, which even then is not frequent enough.

Dan East
Pejo Software - Per · 30 Dec 2003, 20:04 UTC
Thanks Dan for sharing you findings!
I think I'll have a look at Perforce.
At my daytime job I have been working with PVCS, CM Synergy and ClearCase. So far I prefer ClearCase over the others.
For my own personal projects I have not used any CM tool so far and I can't use ClearCase because the license cost is too high. So if Perforce have some of the features that ClearCase have and is free it is very interesting!
I've been using Visual Source Safe for years, and have used CVS and SCCS with great success as well. One caveat to all this is that smaller development studios tend to forget to back up their source code control journal files and end up losing everything in a catastrophe. I typically backup my working file set to another machine every night as well to be safe, and make a CD image of my work environment for each release of a product.
We use both SourceSafe and PCVS here at work, and other areas of the company are using Endeavor for the mainframe side of the house and ClearCase in the web hosting area. I would never work without source control on a multi-user project, there's just no way. My life is further complicated by the fact that I am the only member of my team at my location, everyone else is 300 miles away. So, when I assign work to someone, it's many times working on a piece of code I began or outlined already, so they need access to it. But then I may need to go in and clean up what they've done, so it's an absolute must. SourceSafe serves us well, for the most part, and that's what we generally use during development, then PVCS from production onward.

That being said, I don't use source control of any kind at home on my own "private" projects (that includes Omnytex projects). I am however exceptionally disciplined about backups, source trees, notations and the like.

This most likely stems from my experience in 7th grade spending about 18 hours coding an interactive model of the human brain on my Atari 800XL, saving it to cassette and then finding a few hours later that the tape was chewed up by the tape player! I spent the next 14 hours STRAIGHT recoding the thing, cursing the whole time, because the science fair was starting in about 16 hours... what I geek I am!

Aaaanyway....

I am essentially doing a manual check-out and check-in every time I work on a project anyway because I go out to my network drive that stores all my source, copy the latest version (or a previous version if need be), work on it and then create a new folder for the new version. Most of the time there's a single version for each day I work on a project, but sometimes there's multiple versions for a given day, depending on what changes I've made. I also keep a changelog within each folder. I have an automated nightly backup to tape as well as to the hard drive in another server of all my source code, and weekly I bring a copy off-site to work and keep it there.

Granted, I don't get all the file-by-file version control that a source control package would give me, but I have to be honest, I don't think I've EVER used those capabilities at work. At work, source control is little more than a repository for code and a way to share with distant team members (although keeping one team member from stomping on someone else' changes is of course well worth it, more than that, it's absolutely necassery!). I honestly can't remember the last time we had to revert a version or restore something or do a comparison or any of that stuff that a source control package IS good for.

Why bother doing all that manually and not just go with a source control package you ask? To put it bluntly, I've had some negative past experiences with source control. As ppcStudios mentioned, I have seen people lose lots of work to a SourceSafe database screw-up. I can happily claim it's never happened to me because I'm just as anal at work as at home and I keep multiple backups of everything I check in and out of official source control, but I have been called in at 1:30am in the morning because some stupid consultant's database blew up and they had a major deadline in the morning and they knew I had copies around to save their asses.

Now, I DID use SourceSafe at home for a little while, and toyed with CVS a bit as well. I don't personally like CVS, and SourceSafe is useable but not great. One nice thing about SourceSafe is that it's easy as hell to install and manage. I think it's probably the easiest to get up and running initially IMHO.

I've never heard of Perforce, but I'm going to go have a look. I wouldn't mind getting my team at work to an open package if possible.

Ok, I think I've thoroughly babbled more than enough. Dan's right, use source control! Or become an incredibly anal retentive geek like me, to the point where your manually doing what a source control package would do for you automatically because, ironic as it seems, YOU DON'T TRUST COMPUTERS WITH YOUR HARD WORK!
First off, when I said I back up after a day's work, I didn't mean daily per se. If I work only half a day, then a quarter of a day, then another quarter of a day, I'll figure I've done a day of work (over three days) and make a backup. I'd do it more often except on Windows, the archiver balks if I try to back up while the open applications are playing with the files. (This is not a problem on Unix.) These are just backups to an archive on the same computer I work on.

Second, I do my backups onto another machine whenever I hit a milestone. These mini milestones are basically little releases I do to myself, where I write up a little release note of what's in the milestone, publish it to a few friends, back it up to another machine, etc. While I was working on my pinball-type project, I did about 8 mini milestones over 300hrs of work, which works out to about a backup per week of work. And if a milestone dragged on a bit, I did an adhoc backup to another machine whenever I got uncomfortable about the amount of code since the last backup.

When I start coding again (soon), I'll probably be more diligent as I'll be working 8hrs a day. I may look at automating this process somewhat. (Easier on Unix, harder on Windows with applications open. I don't like to screw with my desktop once I have all my windows arranged.) One thing I want to start doing is burning CDs of my code (less prone to harddrive failure), and putting them in the garage (closest off-site site).

In my professional past, I've used both Visual SourceSafe and CVS. I have indeed found Visual SourceSafe to munge projects now and then, but that was 5 years ago so maybe it is better these days. 1-4 years ago I used CVS professionally, it didn't seem to munge projects but some complained of weirdness now and then. We could never discover if it was actually CVS or just flaky clients.

So, as fzammetti hinted at, that's one reason I just do the ad-hoc backups manually. I know that I am in control of my assets. Basically, I have the discipline to keep detailed (enough) logs of what I do at any particular time; that covers the accounting aspect of it. I keep periodic snapshots of my entire project source tree in dated archives, which covers the history aspect of it. And I make periodic backups to another machine, which covers the backup aspect of it. I try to work these manual activities into other necessary tasks (e.g. bundling into a mini milestone release) to reduce the impact of them. Later I plan to burn to CD, and perhaps automate the process a little more, or just start using CVS or try Perforce.

So what I'm saying is that you need a solution that provides accounting/history/backups, even if that system isn't a source code control package. But I'm also saying that if you have never used a source code control package, you owe it to yourself to try one so you know if it is a good solution for you. (It probably is.)
Here's a timely book review (on Slashdot.org):

http://books.slashdot.org/article.pl...

Pragmatic Version Control Using CVS

From the authors of the excellent book The Pragmatic Programmer.
I just thought of another advantage of using source code management software.

It's easy to have scripts that run nightly, taking a full snapshop of the source code under management, building it, performing automated tests on it, and emailing the results somewhere.

Another thing I used to do is have a few scripts run metrics over the source code every night. This would give a useful summary such as how many files were present, how many lines of code the project had, etc. At the end of the project, we charted the lines of code per day in Excel. :-)

These sort of automated nightly tasks are easy when the authoritative version of the source code is in one place.
Source Control is vital. If you are not using it, you are not serious about software development :D

I use Source Safe at work, but we will be changing because it sucks badly.

For home I use Subversion and TortiseSVN which are free. Very good.
At home, I/we use a Linux CVS server setup, with tortoisecvs on the frontend. Each night the repository is backed up onto a mirrored RAID.

At work, I/we use a CVSNT setup on our server, again with tortoisecvs on the frontend. It took a while getting some people used to it, but now they seem to want to use it for absolutely everything :)

I keep meaning to try subversion, but it's way down in my priority list right now.

(I tried using VSS a couple of times, but decided that I just plain hate it).