Design Code Better With Inferior Version Control

machupichuwallNew tools come out for software development all the time, usually they do more good collectively for productivity than not, but sometimes the limitations of the past had their hidden gems as well.  Our industry is obsessed with the latest greatest thing, I’m not a curmudgeon that’s going to badmouth everything that came out since 1990, but like everything else, the truth is somewhere in the middle of those 2 extremes.

I was lucky to have started my professional career before the advent of Git and Mercurial so I got a couple good years using the previous generation of version control software (VCS).  The major difference between using SVN (a previous generation VCS) and Git for me was the ease of managing branches with Git.  With SVN it was such a hassle, it was rarely done by me.  With today’s VCS’s you use branches all the time for things like trying out experimental changes or editing things without getting in the way of your colleagues.   Just because our VCS’s didn’t have branches didn’t mean that we didn’t do these things though.  What I, and I imagine alot of people, did was edit our code’s design to be more flexible so that with one line of code I could toggle the behavior of the program.  All you had to do was make sure your object allocations were inside factory functions then introduce a new interface so that just swapping the factory function would change everything.  It was a bit more work but it left a lasting modular plugin point to your code that could be used later and usually forced a more clear definition of the relationship between the objects via the interface.

I’m sure you are already seeing the danger here; if over prescribed this could lead to a more confusing, overly modular, code base.  It was something I was always cognizant of, and it never became a problem that I saw, but I respect the danger.  Today I use the branching the tools provide, but more than once I’ve recognized in hindsight some branches as missed opportunities to make my design more dynamic.  Opportunities that I would have seized in a previous age out of necessity.  So, we should see branching and modular design as overlapping tools and just make sure you weigh the benefits of both before you default to VCS branching.  My guess is that 10% of the time you might want to modularize your design… then you can still branch, it will just be a single line difference.

photo credit: Remon Rijper via photopin cc