I’m writing an article together with a friend on what a good function is (in any programming language), and got curious what the OCaml community is thinking. So, what are your thoughts? What is a good function, and how do you keep it good?
Some aspects to consider:
- Contract (post- and pre-condition)
- Pure, referential transparent
- Testable, mockable
- Name and how naming relates to the domain
- Number of arguments
- How to behave in case of failure (assertions, exceptions, different return values)
- Empirical evidence for recommendations (e.g. correlation between size and fault density)
And so on.
One draft of the article available here: What is a good function?