← Back to context

Comment by smush

6 years ago

Came here to post this. I second this book heartily. If you design your types to be DD with raw, valid, invalid data then by the time you actually get to the database or API, you are sure that your code has passed through however many compile-time enforced validity checks (if you use F# or similar static strong type PL) before it got to this point.

That way, you don't need nearly as much defensive coding re: null checks etc. because the data has gone from 'some client typed some value in an input box, hope its valid' to 'this is an Address line that has been confirmed to be valid structure to pass to downstream systems'.

Pit of success is so much better than peak of success, and much easier to get in a static typed functional language vs. an OO language in my experience.