Why Version Control Is Critical To Your Success

using version control is important to a project's success

They are known by many names: verison control, source control, revision control. Regardless of how you call it, a version control tool is critical to the success of your software project. In its most basic form, a version control system is a tool that allows you to store a modification history of all your code.

This concept is used in many other systems including Wikis and incremental backup solutions. Version control tools for software go far beyond a simple history of code modifications, however. They increase productivity, allow for concurrent development of large projects, maintain multiple versions (branches) of the same project, and much more.

A Brief History Of Version Control

Version control has been around for a long time. The earliest system is considered to be SCCS, developed in 1972. Since that time version control systems have evolved quite a bit. Eric Sink, author of the excellent (and free) book Version Control By Example splits version control systems into three generations.

First generation tools required a file lock that allowed only one developer to work on it at any given moment. In addition, developers could only perform operations on a single file at a time. Second generation tools improved significantly on these limitations. CVS, an early second generation tool provided support for operations on multiple files and concurrent editing by multiple developers.

Third generation tools introduced the concept of decentralized repositories. Where first and second generation tools required a central repository that stored all project code, third generation tools take a different approach. Instead of using a client/server model these tools use a peer-to-peer model. In third generation version control tools each developer retains a complete local copy of the repository.

Version control systems of today are incredibly powerful and robust. Both second and third generation tools are perfectly acceptable to use. Which tool you or your team would use depends largely on personal preference, budget, and individual needs.

Why Use Version Control?

There are many important functions provided by a version control system that are indispensable in software development.

Code Modification History

Version control provides a complete history of every commit made by every developer. Since modern tools allow commits of multiple file changes at a time, this allows for easy tracking of related changes. It also makes it possible to perform a diff between any two revisions of a source file.

If you notice that something broke in your project that worked before, you can simply roll back one revision at a time until you find the revision that caused the regression. Without version control you give up the benefit of seeing a diff between the state of the code when it worked and when it broke. In addition, it’s also very useful to see the changes you’ve made before you commit them. This gives you an extra chance to find and correct mistakes.

Concurrent File Editing

When working in a team there are times when multiple developers need to edit code in┬áthe same file. At minimum basic file locking is required to prevent developers from overwriting each other’s modifications. Some version control systems allow file locking, but using locking is not recommended. All modern versioning tools allow multiple developers to modify a file at the same time.

In a client/server tool when a developer attempts to commit a file that was modified on the server, the tool will require him to resolve conflicting differences between the two. In a peer-to-peer tool, the repository is stored locally so conflict resolution takes place when pulling or pushing changes between peers.

Tagging

One of the features of version control tools is the ability to create a snapshot of the codebase at any given moment. Such a snapshot is called a revision tag. Tagging is useful because it allows you to mark the state of the codebase when it is stable (thus making a release tag) or created automatically each time a build is generated.

Tagging can be useful for tracking product releases, although in many cases you will want to create a separate branch for each release. In older version control tools branching was an expensive operation, and branches were difficult to work with. In today’s tools branching is very inexpensive and thus used more commonly.

Branching

Branching is probably the most powerful feature of version control. The term comes from thinking of your commits as a continuous tree trunk. By default any changes you make go to the trunk. You can then create tags along the trunk that mark builds or releases. However there are many limitations to this. For instance, if you make a tagged release you have no way maintaining that release separately from the unstable development code that follows.

This is where branches come in handy. A branch is literally an offshoot of the code in the trunk. To the developer, a branch looks like a complete copy of the code in the trunk. In reality verison control systems of today are optimized for branching and typically store only the differences between the branch and the trunk, thus making the operation inexpensive.

Branches allow you to maintain a separate copy of your project that is not simply frozen in time like a tag is. Branches can be updated individually without affecting other branches or the trunk. This means you can fix a bug in the release branch and make a new release, then merge that fix into the trunk. Thus you can easily maintain one or more releases of your project while developing new features in the trunk. In some cases branches are also used for developing experimental features which are merged into the trunk later on.

Merging

Eventually developers that branched code end up performing a merge at some point down the line. Merging is the act of combining changes from divergent codebases. It typically occurs between two branches, or between a branch and the trunk. For instance, a merge takes place when a bug fix in a branch is applied to the trunk. Without support for merging changes branching would be similar in usefulness to tagging.

It’s worth mentioning that merging of changes used to be a very painful process. It was so bad in fact that many developers simply avoided branching and merging altogether. Today’s version control tools have very robust branching and merging features, and there should be no excuses not to use them.

Who Should Use Version Control?

The short answer is everyone. If you are a member of a software team then it’s probably easy to see that without version control chaos would ensue. However, version control isn’t useful just for teams. Many of the benefits apply to solo developers as well.

For instance, having a history of all modifications is just as useful when working alone as with a team. Version control is incredibly useful for tracking down regressions regardless of how many developers are working on a project. The benefits of branching are universal as well. After all, even a solo developer will have to make and maintain releases of their project.

Which version control system should you use? Any version control system is better than none. You are better off even with the archaic CVS than nothing at all. Stay tuned for a future post where I will write about my experiences with version control tools and my recommendations.

This post includes Open Monumenten Dag 2010 by -JvL- used under the Creative Commons Attribution 2.0 Generic license.

Using Gmail Filters To Deal With Email Overload

Gmail filters are a powerful solution to overwhelming amounts of email.

Last week I saw Ari Meisel speaking at an NJ Tech startup event. Ari gave a talk about various ways to improve your productivity and reduce how much time you spend on less important things. One of the universal issues that people face today is dealing with enormous amounts of email. Ari’s presentation gave me some ideas on how to improve my Gmail workflow. If you use Google’s mail service there are many powerful Gmail filters that you can make use of to help you cope with the influx of email you get every day.

Using The Gmail Priority Inbox

One of the tips Ari Meisel gave at his talk was to split your mailbox into two parts: priority or important email, and optional email. Optional email includes anything that can wait for you to look at it and has no urgency attached to it. This includes things like notifications from Facebook, Linkedin, Twitter, or any other website that you get low importance messages from. Ari also suggests that any email that has the word “unsubscribe” in the body should always go in the optional folder.

Obviously Gmail has no folders, but it has labels which serve the same purpose. Gmail by default has a flat style inbox that shows all messages you get in one long list. However, Gmail also has an option to use a priority inbox. If you go to the Inbox section in Settings, you will see that you can select an inbox type where one of the options is Priority Inbox. When you select this inbox type you will see below the default configuration Google uses.

The default setup shows three sections: Important and Unread, Starred, and Everything Else. The idea is that Gmail can intelligently figure out which messages received by you are important. This is done using an algorithm that takes into account the sender, what you typically do with the email from this sender, how often you email the sender, and so on.

Theoretically if the intelligent algorithm works properly Gmail will implement Ari Meisel’s concept automatically. You simply have to change “Important and Unread” to just “Important” in the options and you get important messages in one section and optional in the other. However I personally am not too keen on trusting an algorithm to figure out what’s important to me, so I decided to customize my priority inbox with some clever filtering.

Customizing The Gmail Priority Inbox

The default configuration for priority inbox may suit some people, but I wanted more control over how my email got sorted. I created a label named “priority” (the word “important” is reserved by Gmail and cannot be used for labels) and set the first priority inbox section to display only emails with that label (this can be set in Options for the section).

I also created a label named “optional” and set the second section to display only optional emails. I then set the Everything Else section to be hidden when empty (which effectively makes it permanently invisible) leaving you with two sections: priority and optional.

As my main criteria I decided that email sent by someone in my Gmail Contacts list should be considered important. After all, if I put someone in my contact list I probably want to hear from them. Unfortunately Google does not provide an operator to filter by whether the sender is in your contact list. However, there is a workaround.

Gmail Filters For Important Email

Although you can’t filter by your contact list, Gmail does let you filter by whether or not someone is in your Google+ circles. It’s hard to say if this was an intentional choice by Google, but it does mean that you have to add all of your contacts to Google+ circles. The only issue with this is that the contact will be notified that you added them to a circle (unlike with Facebook they don’t have to approve for you to add them).

When you create a filter, Gmail will show a standard dialog where you can supply very basic filtering settings like From, To, and Subject. Hidden in this dialog is a feature that lets you filter by a lot more than you might think. What Google doesn’t tell you is that in the section “Has the words” you can actually use an expression that includes special operators used by Gmail to perform searches.

To mark all email sent by your contacts (those added to circles) as important add a filter and put this expression in the “Has the words” section:

has:circle -unsubscribe

After clicking Continue, check the box “Apply the label” and select “priority”. By adding the unsubscribe portion, you will apply Ari’s rule of making email containing the word “unsubscribe” be marked as optional (as you’ll see below, we apply the “optional” label to email that wasn’t labeled as “priority”).

Of course simply being sent by a contact may not in itself mean the email is important. Gmail lets you filter by additional criteria which comes in handy in determining an email’s importance. For instance if you want to match email that was sent by someone in your circles and addressed to you in TO, CC, or BCC your filter would look like this:

has:circle deliveredto:myname@gmail.com

If you are only interested in email sent by a contact specifically to you, then you would use

has:circle to:me

Note that you need to replace myname@gmail.com above with your Gmail address. For some reason to:me is valid for filtering mail sent to your email address, but deliveredto:me doesn’t work. This seems to be an oversight on the part of Google.

Gmail Filters For Optional Email

Now that we have a filter for important email, we still have to create one for the optional email. This is fairly straightforward in my case. I simply wanted to mark all email as optional if it wasn’t marked as priority. This means the filter checking for whether the email is optional has to run after the priority filter. Although it’s not mentioned in Google’s documentation, the filters you create are applied to incoming email in the order that you see them in settings.

Since we know the order of filter execution we can create a filter that is last to execute and checks all incoming mail to see if “priority” label has been applied. If the filter doesn’t see the priority label then the email is labeled “optional”. The filter criteria is the following (the “-from:me” is added because Gmail applies filters to both incoming and outgoing mail, which means all outgoing mail would be labeled optional and appear in your inbox):

-label:priority -from:me

Click Continue, apply the label “optional” and you’re all set. When you create this filter Gmail will give you a warning, but you can safely ignore it. If you ever edit your “priority” mail filter later on make sure to update the “optional” filter (you can do an update without making changes) so that it always executes after the “priority” filter. This is necessary because whenever you create or update a filter Gmail puts it at the end of the filter execution list.

The above setup will work fine, but there is one thing I found lacking after using it for a while. Even though “optional” emails were being filtered correctly, they were still showing up as unread in Gmail and causing email alerts on my phone. I decided to go one step further and set the “optional” email filter to mark the emails as read and to star them. This prevents me from getting distracted when optional emails arrive, and the star on the email lets me see that I haven’t read it yet.

Note that you may want to also turn off “conversation view” in General Settings. Gmail will group emails with the same topic by default, but doing so overrides filtering settings. For instance if a contact sends you and some others an email, and a person who is not in your contact list replies to it, it will still appear in the priority inbox. This is because the original email was marked priority, so replies are grouped together. If this is what you want, you don’t need to do anything. If you want replies from unknown people to go to be sent to the optional box then turn off conversation view.

Muting The Gmail Spam Counter

One of the better known features of Gmail is its excellent spam filtering. This of course saves you a lot of time since Google’s spam detection algorithm produces almost zero false positives. Spam filtering is great and happens automatically, so you don’t really have to do anything about it.

Nothing that is, except for one annoying thing: for some reason Google decided to show an unread spam counter on the spam folder link. This is distracting, and can also fool you into thinking you have unread mail when you glance over at Gmail in your browser.

To prevent Gmail from showing an unread spam count you will need to create a filter that automatically marks as read any spam messages you receive. To do this, go to the filter section in settings and create a new filter. To make the filter apply to messages marked as spam, type the following in the “Has the words” box:

in:spam

When you click “Continue” you will see an ominous warning. Just ignore it and click OK. On the next pane, select “Mark as read” and you will no longer be bothered by the unread spam counter. Since spam is deleted automatically after 30 days you don’t have to worry about emptying it out. Which means you don’t ever have to look in that folder again if you don’t want to.

Dealing With Useless Non-Spam Email

As I was looking for ways to optimize my email workflow I noticed that some non-spam emails I get provide absolutely no value to me. I simply play whack-a-mole with them by putting them in the trash when I get them. One example is emails that alert me that my credit card or bank statement is available. Normally I would simply disable this notification, but many banks don’t have that option. With these banks the only way to turn off the email notification is by choosing to receive a paper statement by mail.

I decided to filter out these notifications, but I still wanted to ensure that important email from my banks got through. To solve this problem I created individual filters for each useless email that I wanted to go straight into the trash. In each of these filters I set the “From” to be the email address where the notification came from. However that alone could potentially filter out important messages if they are sent from the same email address.

To make sure that only unwanted messages trigger the filter I included a portion of the email subject that I knew would be identical in all future emails. For instance if the subject is “Your statement is ready for January” then putting “Your statement is ready” in the Subject section would match the entire sentence that includes “for January” or “for March” and so on.

The combination of sender email address and subject creates a unique but repeating email signature that the filter can look for. Once your filter criteria is ready you can decide whether you want to archive the email or delete it. For more information on all the different Gmail search operators you can use, have a look at the official Gmail documentation.

This post includes You’ve Got Mail by Card Karma used under the Creative Commons Attribution 2.0 Generic license.