Pure Function Benefits

  • Pure Functions are easy to test
    • No need to do a lot of setup and initialization. Just call your method
  • Easier to think about
    • You only need to look at the body of the function to understand
    • No need to think about what data is stored in other places
  • Is always thread-safe
    • Even if the function is called from 100 threads, they can't affect each other
    • Changes to the environment cannot mess with a function while it's running

5 / 23