Summary
In this chapter, we introduced the concept of pure functions and studied why they matter. We also saw the problems caused by side effects—one of the causes of impure functions—looked at some ways of purifying such impure functions, and finally, we saw several ways of performing unit tests for both pure and impure functions. With these techniques, you’ll be able to favor using pure functions in your programming, and when impure functions are needed, you’ll have some ways of using them in a controlled manner.
In Chapter 5, Programming Declaratively, we’ll show other advantages of FP: how you can program in a declarative fashion at a higher level for more straightforward and robust code.