wordfor

pure function

noun

Software design

  1. A function whose output depends only on its inputs and which changes nothing outside itself. calculateTotal(items) is pure; saveOrder(items) that also emails the customer is not.

In plain words

  • the function changes things outside itself
  • hard to test because it touches global state
  • same input gives a different output
  • side effects everywhere

See also dependency injection test double (mock, stub, fake) derived state

Find similar words