O'Reilly logo

Functional Programming in C#: How to write better C# code by Enrico Buonanno

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Why function purity matters

This chapter covers

  • What makes a function pure or impure
  • Why purity matters in concurrent scenarios
  • How purity relates to testability
  • Reducing the impure footprint of your code

The initial name for this chapter was “The irresistible appeal of purity.” But if it was so irresistible, we’d have more functional programmers, right? Functional programmers, you see, are suckers for pure functions—functions with no side effects. As you’ll see in this chapter, pure functions have some very desirable properties.

Unfortunately, the fascination with pure functions and what you can do with them is partly why FP as a discipline has become disconnected from the industry. As you’ll soon realize, there’s very little ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required