- You need to master the language itself, I suggest starting by reading a good beginner book from this list.
The goal is to increase code's readability and testability.
- Find simple cases where a single function does "too much" and refactor it. For example, if there is a function that converts a list of strings into numbers with the base 10, it could be refactored in steps
var result = 
- Write little functional helpers, like
partialRightused above youself first. It is very simple, yet you will get used to writing higher-order functions that take and return other functions. For example, here are my favorite utilities; see if you can implement them.
As you get more comfortable with these transformations, the amount of functional code in your programs will slowly grow.
- Try to decrease the number of impure functions that use outside state. Some functions have to perform "dirty" tasks, but majority of data transformations can be made pure. Pure functions are simpler to understand, test and reuse.
- Become familiar with large libraries of little utility functions, like
Ramda and Lodash - most of my own code
is based on reusing functions from these libraries. For example, I do not use my own
unary, but rely on Ramda's
const R = require('ramda')
- Get comfortable working with wrapped values instead of "primitive" objects. Such wrapped
values have fancy names like Functors and Monads, but just think about them as values with
extra logic for applying functions to the wrapped value. For example
gives good examples replacing
if (value === null)statements with cleaner functional code.
- Browse my functional presentations slides for quick examples
- Join the Ramda gitter channel gitter.im/ramda/ramda where any functional question is welcome and answered pretty quickly.
- Apply functional programming practice to reactive programming, for examples read MVC to FRP blog post.
- If your coworkers object to using functional solutions, you need a strategy to overcome their objections
- Review the Functional Programming Jargon
- Read whatever catches your eye in the very very long Awesome Functional Programming list on GitHub.