loading words...

Mar 19, 2019 22:50:59

Crash Early, Crash Often

by @valentino | 220 words | 65🔥 | 363💌

Valentino Urbano

Current day streak: 65🔥
Total posts: 363💌
Total words: 173751 (695 pages 📄)

A lot of people think that crashing is bad. No matter what. While I agree that in most cases it is bad to crash, in a few cases, mostly during development, is actually something you should consider doing more often than you do nowadays.

If a condition is impossible and when it happens either it's because of a programming error, or because of something that is set up wrong (not a runtime issue) you need to crash right there. It's way easier to debug problems like that than just silently continue and than finding the app in an undefined state for which the cause is impossible to find.

Some examples where it is good to have "crash testing" (aka crash in case of a problem so you can catch it more easily while debugging):

- Failure to load an asset in the app bundle

- Failure to create the database the first time we launch the app

- Failure to load the initial application state

This can be avoided by having good unit tests. If your app is fully unit tested than it is unnecessary since eventual problems are going to be caught automatically every single time. But for some project, it is not possible to create tests while prototyping for many reasons so this might be a good workaround in the meantime.

Originally published at www.valentinourbano.com

contact: email - twitter / Terms / Privacy