Nate Meyvis

The long run comes quickly

Software engineers often choose whether to take on some technical debt in order to hit a deadline quickly. This can take many forms; here are two:

  1. You need to make and run a script; should you factor out significant chunks of logic and test those independently?
  2. You need to ship a feature, and you're adding functionality to a React component that most properly would be managed by its parent component. Do you do the work now to lift up the state?

As always, it depends. But if my experience is any guide, most of us are too quick to take on the technical debt.

Most importantly (and most interestingly!), we way overestimate the "time to relevance" for the decision in question. The state management feels like a high-level, abstract consideration, but it's pretty likely to be relevant the next time you need to implement or fix anything. It feels like testing the script is a matter of long-term maintenance, but very often those tests will be useful for debugging later today.

We also overestimate the cost to avoid the problem. The tests aren't that hard to write and run, especially with modern tools. It's usually not as hard as it first seems to move some state around. And so on.

So, the costs to avoiding tech debt are often lower than they seem, and the benefits are higher. Also:

  1. You often get, effectively, a discount on your time by doing it now, because now is when you know the code the best and can do the best job the most quickly.
  2. The parts of ourselves that tell lies in order to get out of work are eager to jump on excuses like "I need to cut this corner in order to ship quickly."
  3. We sometimes intuitively judge these questions by comparing coding time (e.g., to implement the script with tests) to coding time (e.g., to implement something without tests). But the total time to ship something often involves significant build, review, and deployment time. The extra coding time is often a much smaller part of the total effort cost of shipping the code than our intuition tells us.

Again, there's no single answer here. It really does depend. But people make a lot more mistakes in the cutting-corners direction than the going-slightly-too-slow direction. If the decision is at all close, just go ahead and do it the right way, right now.