Checklist for creating good and testable code

Alvaro Andres Pinzon Cortes
1 min readNov 15, 2018

--

Low-level functions checklist

  • The function should only be responsible for one task in a process.
  • The functions should receive as input all the variables and resources that they need to execute their task.
  • The functions should produce an output or directly change the state of some element, but not both.
  • The output or change to a state produced by the function can be tested easily with an assertion.
  • Avoid side-effects in your function, because they can’t be tested with the assertion.

Code design heuristics

Gather together the things that change for the same reasons. Separate those things that change for different reasons.

Relevant links

--

--

No responses yet