The Bug That Changed How I Write Code Forever

D
Dick Edidiong Bassey
·

A financial reconciliation loop. One off-by-one error causing settlement to drift by a fraction of a penny per transaction.

At 2 million transactions a year, that fraction adds up.

Three days to find it. Thirty seconds to fix it.

What I learned permanently: write code that makes wrong states unrepresentable. Use database constraints to enforce correctness. Write assertions that fail loudly. Log every financial state transition with before-and-after snapshots.

The best debugging is the debugging you never do because the code cannot produce the wrong answer. Design for that.

— Dick Bassey | DevDick | 2018