top | item 41176417

(no title)

sam_perez | 1 year ago

Beautiful.

----------------------------

This controller is intentionally written in a very verbose style. You will notice:

1. Every 'if' statement has a matching 'else' (exception: simple error checks for a client API call)

2. Things that may seem obvious are commented explicitly We call this style 'space shuttle style'. Space shuttle style is meant to ensure that every branch and condition is considered and accounted for - the same way code is written at NASA for applications like the space shuttle.

----------------------------

^^^^

This bit reminds me of exhaustive checks in typescript code. I try to use them all the time.

https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...

discuss

order

jeremyjacob|1 year ago

The newer `satisfies never` is great for this purpose. It’s also convenient with if else chains if that’s more one’s style.

bubblyworld|1 year ago

Hah, years of writing ts for various contracts and I had no idea that never could be used like this. Thanks!