When I’m working from home, I will usually work in a virtual machine that is sitting in a VM cluster on my company’s servers. When I’m in the office I’ll work primarily on the box that is siting under the desk. This arrangement started out for purely practical reasons. But I’ve discovered something very useful about doing development in two different environments: it forces me to get everything checked into source control. It is one thing to use source control in principle. But when you are working on a small team, it is really easy to fudge. I might for example create a SQL script for development purposes, but to save it on my desktop. Ooops, now I don’t have it anymore when I’m in my other location and I need to go looking for it. Getting in the habit of working in multiple environments means I’m much more conscious about getting everything checked in and hence organized.
There are two more benefits of using a VM that I’ve discovered. The first goes to general development work habits. I have a very flexible work schedule and don’t always decide if I’ll be working from home or from the office until the evening of the prior day. So I get in the habit of checking in my work every day. Which in itself is not all that valuable. But it leads to a focus on getting all my code to a clean state by the end of the day. I don’t want to check something in that might break a build. So I make sure that I leave everything in a clean and complete state before I go home. I find that this helps me to be very focused on the task at hand. The build works. Unit tests are complete and I get that satisfying green check mark. It’s a whole lot better to start a day without something that has to be finished or fixed.
The second benefit relates to working from home. If there was a power outage or some system update over night my desktop box might be unavailable and I might not be able to connect to it remotely. But since my virtual machine is running on monitored servers, it is more likely to be available.