design
design copied to clipboard
Type checks/fail fast
Generally, the first few lines of a function should assert the type specification of the arguments, using some combination of vctrs, S3 is functions, NSE/enquoting functions, and base/rlang scalar type predicates (is_string(), is_symbol(), is_expression() etc). This ensures that the user gets an error message quickly if the function has been fundamentally misspecified.
Don't rely on type errors coming from subsequent function calls because the errors will be less informative.