Peace of Mind from Version Control

"Do you want to save your changes?" No, not if I just added temporary debugging code. But, Yes, if I also added production code. What to do?

Peace of Mind from Version Control

Does this sound familiar?

You're debugging an Access application.  You're making changes to a bunch of forms, standard modules, and class modules.  There are two or three forms open in the user interface.  You find the bug and update a handful of functions to fix it.  Along the way, you also add some temporary debugging code: a MsgBox here, some Debug.Print statements there, maybe even a Resume 0 statement (if you haven't yet learned about the Extra Resume).

When you're done debugging, you close all the open forms.  Two of them close without incident.  When you go to close the final form, though, Access wants to know if you want to save the changes you made.  But you don't actually remember making changes to this form.  What do you do?

Hmmm... this feels like a loaded question.

A Moment of Indecision

As a young developer, I would agonize over this seemingly innocent question.  

If the only changes I made were temporary debugging changes, the answer should be No.  After all, I wouldn't want my debugging code to accidentally make it into production.

If the only changes I made were intentional changes to production code, the answer should be Yes.  After all, I wouldn't want to lose my hard work.

When in doubt...I used to click No

Before I used version control, I erred on the side of not saving my changes.  After all, I had no good way of isolating which changes I had just made.  Sometimes, if I had written both debugging code and production code, I would intentionally close the form without saving.  Then, I would open the form back up and rewrite just the production code.  Besides, if it took me four minutes to write the original code, it would only take about one minute to rewrite that same code.

Without Version Control: Better safe than sorry...I'll click No if I can't remember what I changed.

Inevitably, as soon as I clicked [No] on the save dialog I would remember that the past 45 minutes I was, in fact, working on the code behind for that very form.  And I had just lost nearly an hour's worth of work.

The great irony of this approach is that I was clicking [No] to be on the safe side.

When in doubt...I now click Yes

After awhile, I got tired of walking a high wire with no net.  I began using version control for all of my Access applications.  Besides the obvious advantages of version control, I've enjoyed several less obvious side benefits.

One side benefit of using version control is that it is very easy to roll back to a previous version of your code.  This means there is less angst around each save.

With Version Control: Better safe than sorry...I can always roll back to an earlier revision.

With version control, I don't worry about accidentally saving unwanted changes.  Now, my default behavior is to always click [Yes].  After all, the worst case scenario is that I just roll back my changes and get back to where I would have been if I clicked [No].  Best of both worlds.

Image by Michal Jarmoluk from Pixabay

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