Does your code reward the right behavior?

We have rooms in our house; bedroom for sleeping, kitchen for cooking, dining room for dining, and my office is meant for work but in practice doesn’t reward work. There aren’t big distractions; but with the size of my keyboard, the (lack) of depth to my desk, and the fact that I have a curved monitor that *doesn’t* support a Vesa mount, I end up spending as much time fighting with the things on my desk as I do working, or at least it feels that way.

The solution, of course, is to buy furniture / set up all the things I need so that I don’t need to move anything around to work and to put the effort into ensuring that the entire focus of my office is work.

It sounds easy, right?

So why don’t we do that in our code bases?

A codebase should reward certain actions and discourage others. For instance, if you write Microservices, and you want to be sure you can’t reuse code, then setting up micro-repositories (one repository per service) might be an approach to solving that. You could also solve it through manual human intervention or “style guides”, but if we’re being honest we know they’re either ignored or used as a cudgel against those we don’t like. A mechanical guard against actions we don’t want developers to take in the codebase is the best way to go — it’s enforced by the unfeeling machine, and we don’t have to worry about hurting human relationships over the problem. Micro-repositories do this for Microservices (the fact that they both have ‘micro’ in front of them is coincidental, one does not imply the other).

We say this in our code, but not enough in our infrastructure or in our team setup: The right thing should be easy, the wrong thing should be impossible.

One step towards operating proficiently as a software team is to ensure that your team’s procedures, setup, guidelines, and rules that you want enforced are enforced at a mechanical level — a level that results in very neat paths for people to follow without devoting brain power to it.

Programming is hard enough without devoting brainpower to rules that should be enforced mechanically.

Leave a Reply