Software Design/Begin the name of a function with side effects with a verb

From Wikiversity
Jump to navigation Jump to search

Checklist questions:

  • Names of functions with side effects begin with a verb, rather than just being a noun phrase?

Why[edit | edit source]

  • Thrutfulness
  • Easier to reason about the composition of side effects in implementations of functions in programming environments that don't allow expressing side effects on the type level => less cognitive load and more robustness.

Why not[edit | edit source]

Beginning the name of a function with side effects with a verb doesn't provide much distinction in environments which support expressing side effects on the type level and where there are plenty of side-effect-free functions with names starting with verbs already. In such environments functions with side effects may have a dedicated prefix, for example, unsafe- in Cats Effect library for Scala.[1]

Related[edit | edit source]

References[edit | edit source]

  1. Cats Effect: IO. "Unsafe" Operations