Refactoring towards functional programming

1 minute read

This is part of a series on refactoring towards functional programming.


Introduction
  Imperative versus declarative programming
    Functional principles for better code
Designing a functional list API
    Writing a filter function
    Transforming with Map
    Isolating side effects with ForEach
Functional composition
    Functional composition through extension methods
    Refactoring to point free
Functional refactoring conclusions


Introduction

If know the basics of functional programming, click here to skip ahead to the code.

This series of blog posts is meant to give you a practical introduction to functional programming through the use of common list operations. No prior knowledge of functional programming is required but some familiarity with programming in general is assumed. The language used in the example code is C# while the principles taught are language agnostic.

The motivation behind these posts is to introduce functional programming through concrete examples with clear benefits. I’ll skip most FP jargon but won’t shy away from complexity. Functional programming has a high barrier of entry, not because it’s inherently harder than object-oriented programming, but because it is unfamiliar. We’ll jump off the deep end with higher order functions and functional composition, but in the end, we’ll have made an API you might be familiar with. You may be surprised to find that you have been doing some functional programming all along.

Next up, Imperative versus declarative programming

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...