Learn to Love Text-Based Version Control with "Highlights for Children"

Why use text-based version control for visual objects like forms and reports? I'll tell you why, but first, find all the differences between these two pictures...

Learn to Love Text-Based Version Control with "Highlights for Children"

I wrote several articles about how I implemented a custom VBScript file that I use as the basis of my company's Microsoft Access version control system.  In the culminating article, Putting It All Together, Huy Truong posted the following in the comments section:

Hi Mike, I finally got the script run. I wonder if you could give me some ideas on how to use the output, as they are mainly text files. (This could be because I still don't understand exactly how to work with version control.) Thanks, Mike!

Here was my response:

The way modern version control systems work is that they keep track of the differences between two versions of a file.  This works great for text files because you can compare the differences line by line in a human-readable way.  It does not work so well for binary files, like pictures, because seeing the difference in the raw binary data is not meaningful in any sort of human-readable way.

The same goes for Access files.  Comparing the differences between two versions of an .accdb file at the byte level would make no sense. Instead, we use the SaveAsText function to convert every Access object, including forms and reports, into a text-based format.  This allows us to compare one version to the next more easily.

That is all just background information for the unique challenges of integrating Microsoft Access with version control.  I strongly recommend you read an introduction to version control itself, whether that is Git or Mercurial.  I personally love Mercurial (especially TortoiseHg), but unfortunately, Git emerged as the clear winner of the DVCS wars.  If you have no attachment to an existing version control system, you should definitely learn Git.  It's the industry-standard version control system.

After writing my response, I thought of an example that might help illustrate why text-based files work so well for version control.  It may seem odd to use text files to compare primarily visual objects, like forms and reports.  As you'll see, though, it actually makes the comparisons way easier.

Check and... Double Check

Fun fact (for me anyway): I went to high school in Honesdale, PA, the home of Highlights for Children magazine.  One of the most popular features of their magazine was a spot-the-differences game called "Check and... Double Check."

The idea is that you had to spot all the differences between two photos.  Here's a sample image from their website:

Take a few minutes and see how many differences you can spot.  Keep track of the number of differences you found.  Yes, there will be a test later.

...

Are you done?  Take your time.

...

Now, imagine if this were two different versions of a form in Access.  Imagine trying to identify the differences between two forms just by looking at them visually.  

Keep in mind that with Access forms, you can't even see some differences.  For example, if a textbox is locked in one version of a form but unlocked in the other version, that textbox will look the exact same on screen.

SaveAsText

Let's imagine there was a SaveAsText function for the Check and... Double Check images.  Saving the top image to text might result in a file that looked like this:

Begin Object Man
    HasChefHat = True
    HasApron = True
    ApronHasStrings = False
    GrillUtensil = Fork
    PantsColor = Black
End Man

Begin Object Boy
    HairColor = Black
    ShirtSleeves = Short
    PantsStyle = Cuffed
    ShoeColor = White
End Boy

Begin Object Dog
    VisiblePawCount = 4
    EarLength = Long
    HasCollar = True
    NoseColor = Black
    HasTail = True
End Dog

Begin Object House
    HasShingles = False
    WindowSize = Small
    GlassHashCount = 3
End House

Begin Object Grill
    HasHood = True
    FoodOnGrill = Sausages
    VisibleLegCount = 4
    CharcoalContainer = Bag
End Grill

Begin Background
    BirdsInSky = False
End Background

Saving the bottom image to text might result in a file that looked like this:

Begin Object Man
    HasChefHat = True
    HasApron = True
    ApronHasStrings = True
    GrillUtensil = Spatula
    PantsColor = Black
End Man

Begin Object Boy
    HairColor = Black
    ShirtSleeves = Long
    PantsStyle = Striped
    ShoeColor = White
End Boy

Begin Object Dog
    VisiblePawCount = 4
    EarLength = Medium
    HasCollar = False
    NoseColor = Black
    HasTail = True
End Dog

Begin Object House
    HasShingles = True
    WindowSize = Large
    GlassHashCount = 3
End House

Begin Object Grill
    HasHood = True
    FoodOnGrill = Burgers
    VisibleLegCount = 4
    CharcoalContainer = Box
End Grill

Begin Background
    BirdsInSky = True
End Background

Unified Diff Format

Looking at the two text files side-by-side, they're not much easier to find the differences than if we compare the images themselves.  But, since they are text-based, we can use the unified diff view to see the changes quite clearly:

This is the real power of text-based version control.  It highlights every difference between two versions of an object in a human readable form.

Dost Mine Eyes Deceive Me?

OK, be honest.  How many differences did you spot in the original picture?  How long did it take?  

And how long did it take you to spot every single difference in the text-based unified difference?

For those playing at home, here are the differences between the top and bottom images (numbered for your convenience):

  1. ApronHasStrings = False --> True
  2. GrillUtensil = Fork --> Spatula
  3. ShirtSleeves = Short --> Long
  4. PantsStyle = Cuffed --> Striped
  5. EarLength = Long --> Medium
  6. HasCollar = True --> False
  7. HasShingles = False --> True
  8. WindowSize = Small --> Large
  9. FoodOnGrill = Sausages --> Burgers
  10. CharcoalContainer = Bag --> Box
  11. BirdsInSky = False --> True

Seeing the Light Yet?

If you're on the fence about trying version control with Microsoft Access, I hope this demonstration helps you see the light.  In my opinion, writing production Access applications without version control is like High Wire Walking With No Net.

If you're ready to give version control a try, here's a great way to get started: A Quick, Free Way to Try Version Control with Microsoft Access.


External references

About Us | Highlights for Children
About Us | Highlights for Children
History | Highlights for Children
History | Highlights for Children
diff - Wikipedia

Referenced articles

Putting It All Together
I expanded on the original decompose.vbs script. The code below is the culmination of more than 50 individual changes and tweaks over 10+ years.
An Homage to Mercurial
I believe without a doubt--even knowing what I know now--that I made the right decision at the time. If I could go back to 2009 and do it over again, I would still go with Mercurial. If I were starting from scratch in 2020...that’s a different story.
High Wire Walking With No Net
In those early days, our method of “source control” was making regular copies of the front-end database and appending a date to the filename. This was....less than ideal. The problem is best illustrated with a quick story.
A Quick, Free Way to Try Version Control with Microsoft Access
Curious about getting started with version control in Microsoft Access, but don’t want to commit a lot of time or money? This could be just the solution for you.

All original code samples by Mike Wolfe are licensed under CC BY 4.0