Commit your code as if it could be accidentally deployed

Written by Matthias Noback / Original link on Jan. 31, 2022

The one simple trick to do a better job as a programmer is to git commit as if your commit could be accidentally deployed (and it wouldn't break the production environment...)

Why would this improve your work? Because it pushes for improvements in several areas.

If a commit needs to leave the project in a working state, you need to:

  1. Be able to prove that after making your changes, the project is in a working state. This forces you to put automated tests in place.
  2. Be able to make changes that don't break existing code, or that only add new features. This forces you think about first improving the existing code design to allow for your change to happen.

To practice with the latter, I recommend learning about the Mikado method. It makes it easier to recognize prerequisites for the change you want to make, and then forces you to enable the real goals by implementing the prerequisites first.

This process is also known as "making the change easy, then making the easy change". An amazing result of applying this process is that after some practice you'll be able to make many, much smaller commits during the day. Each of those commits will leave the project in a working state. To me this always feels great because:

  1. I'm not worried that my change breaks something.
  2. I only make small jumps between stepping stones and I'm safe on each stone.
  3. I can switch tasks when I need to.

Consultancy secrets

As a consultant I apply this "trick" to trigger improvement of the development process. I like to work with development teams on one of their real programming tasks, as an ensemble. We use a pomodoro timer, and we establish a goal for the "pomodoro" (25 minutes). Reflecting at the end of the pomodoro we often conclude two things:

During all this time we don't feel safe at all. We don't have a sense of accomplishment either. Realizing this turns out to be a great starting point for improving the development process.


« Domain-Driven Resolutions - What Makes Automated Application Monitoring so Important? »