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...
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.
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):
- ApronHasStrings = False --> True
- GrillUtensil = Fork --> Spatula
- ShirtSleeves = Short --> Long
- PantsStyle = Cuffed --> Striped
- EarLength = Long --> Medium
- HasCollar = True --> False
- HasShingles = False --> True
- WindowSize = Small --> Large
- FoodOnGrill = Sausages --> Burgers
- CharcoalContainer = Bag --> Box
- 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.