Aug 28, 2017 · 1 min read
I highly recommend thinking about programming in terms of mathematical functions. Since indeed, they are.
Somewhat bizarre and awkward functions.
Sometimes we have to strip away the layers of syntactic candy floss of globals and “this” pointers and structs to see them as functions, but yes, indeed they are functions.
I would explicitly argue _against_ total functions.
They have their place. eg. Handling input from users, from the ‘net, from RF, …. handling input from any untrusted source.
However, you should use total functions at the edge of your system to sanitize those untrusted inputs allowing _only_ trustworthy data through.
There after….
- If untrusted data makes it’s way through, is explicitly a bug in your outer layer. You need to find it and fix it before it leaves your desk.
- Any extra code you write to make an inner function into a total function is redoing the work of the functions designed to do that. ie. Duplication and waste.
- Since mostly the outer functions do their job, most of that duplicated code is untested…. and probably buggy.