Listed in order of preference. Pure functions preferred over shells which are preferred over “other” functions.
pure functions:
no side effects
just take data in and data out
they should always produce the same output for the same input (not dependent on result of a DB query, etc)
no mocks should ever be needed
test using unit tests
imperative shell
must only have one path of execution (no branching)
not as critical, but really shouldn’t have any logic
the top level shell needs to decide what to do with errors, but generally it
should do so by passing the final promise chain to another function (a pure
function)
other functions
must be either integration tested or unit tested with mocks
must only be called by an imperative shell or “other function”