Post hoc ergo propter hoc

When temporality becomes causality

Teiva Harsanyi
2 min readNov 11, 2023

--

Saturday morning. I wake up, prepare a coffee ☕, and scroll on Linkedin. I see (yet) another post from a guy praising the benefits of TDD. Here’s the beginning, translated from French:

Since I started practicing TDD, my days are much more pleasant. No more console.log(“HERE”) for debugging.

This person experienced the following temporal sequence:

  1. I have to use console.log statements to debug my code
  2. I am switching to TDD
  3. I am writing tests
  4. I am no longer obliged to use console.log statements to debug my code

Therefore, his logic is the following: I don’t use log statements because I’m doing TDD.

This a logical fallacy, and it has a name: Post hoc ergo propter hoc. In English: “after this, therefore because of this”. Said differently when temporality is confused with causality.

Let’s dissect the correlation between these actions:

A. I use TDD

B. I write tests

C. I don’t have to use log statements

Here C is not directly caused by A; it is caused by B. I don’t have to write log statements because I have some tests, and most likely some good ones. Sure, TDD may help some people to produce tests, but again, TDD is not the direct cause of why I don’t use log statements.

This is a real fallacy. Tomorrow, I could invent a new methodology to write tests; let’s call it Holistic Inclusive Testing (HIT). And I could fall into the same argumentation trap: “Have you seen folks? Before, I had log statements, and now, thanks to HIT, I don’t need them anymore!”. And this would be wrong.

In the realm of simplification, the temptation to attribute outcomes solely to a specific practice or methodology can be high. Let’s resist and be mindful of this trap when sharing technical content online.

The irony in this story? Now my coffee ☕ is cold…

NOTE: This post is not about making fun of this person. It was a helpful example to illustrate my point but not at all a personal critique. Thanks to him for sharing his opinion.

--

--

Teiva Harsanyi

Software Engineer @Google | 📖 100 Go Mistakes author | 改善