Chapter 18

Integrating Functional Programming Approaches

WHAT’S IN THIS CHAPTER?

  • Functional approaches in refactoring
  • Writing new code
  • Finding Likely Candidates for Functional Programming

With all the technical background sorted out in the previous parts of this book, one important challenge remains: applying all those ideas to the everyday scenarios that you face in your work.

This is somewhat similar to learning a new programming language. All programmers have done it before. The first step is to try to remember some of the unfamiliar syntax constructs, so they come readily to mind when a particular element is called for while writing code. The second step is to start thinking the way that new language works. Sometimes different languages have different philosophies. A particular solution that you can come up with quickly may work, but at the same time it may be very different from the solution a more experienced programmer of the same language would choose. In extreme cases of course, languages can differ so drastically that without the right mindset it is impossible to achieve any meaningful results.

Applying functional programming ideas to C# seems easy at first because it isn’t necessary to learn the syntactical basics of a new language. The elements of the language, the tools, are familiar, so you can focus on the philosophy alone. It seems like this should be half the work, but in reality that’s not always true. The problem is that there’s always a way out; the fallback ...

Get Functional Programming in C#: Classic Programming Techniques for Modern Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.