logoalt Hacker News

addaontoday at 2:00 AM1 replyview on HN

But how do you test the recovery path if the invariant is violated in production code? You literally can’t write a test for that code path…


Replies

josephgtoday at 2:38 AM

There is no recovery. When an invariant is violated, the system is in a corrupted state. Usually the only sensible thing to do is crash.

If there's a known bug in a program, you can try and write recovery code to work around it. But its almost always better to just fix the bug. Small, simple, correct programs are better than large, complex, buggy programs.

show 1 reply