Comment by busfahrer

10 hours ago

I think I remember a Carmack tweet where he mentioned in most cases he only considers it once he reaches three duplicates

The "Rule of 3" is a pretty well known rule of thumb; I suspect Carmack would admit it predates him by a fair bit.

I once heard of a counter-principle called WET: Write Everything Twice.

Why 3? What is this baseball?

Take the 5 Rings approach.

The purpose of the blade is to cut down your opponent.

The purpose of software is to provide value to the customer.

It's the only thing that matters.

You can also philosophize why people with blades needed to cut down their opponents along with why we have to provide value to the customer but thats beyond the scope of this comment

  • Why baseball? You don't use the number 3 in any other context?

    If you write a lot of code, the odds of something repeating in another place just by coincidence are quite large. But the odds of the specific code that repeated once repeating again are almost none.

    That's a basic rule from probability that appears in all kinds of contexts.

    Anyway, both DRY and WET assume the developers are some kind ignorant automaton that can't ever know the goal of their code. You should know if things are repeating by coincidence or not.

  • Rule of 3 will greatly benefit the customer over time as it lessens the probability of bugs and makes adding new features faster.

  • "The purpose of software is to provide value to the customer."

    Partially correct. The purpose of your software to its owners is also to provide future value to customers competitively.

    What we have learnt is that software needs to be engineered: designed and structured.

  • One is one. Two is a coincidence. And three is a trend. That's my personal head canon.

    • "Once is happenstance. Twice is coincidence. The third time it's enemy action." — Auric Goldfinger