Functional Programming analogies

Functional programming is a programming style where you use pure functions

Non-Pure functions are like my ex-boyfriend

  1. They might return no value
  2. They don’t need my input
  3. May cause side effects (ask my therapist)

Non-pure function example:

var annoyance = 0;
function exboyfriend(){
annoyance++;
}

As you can see, he returns no value, needs none of my input, and changes a state (has side effects).

State is like glitter

We must be very careful when working with glitter. The motherfucker gets everywhere. State is like that, manage it carefully or you will end up contaminating your code. Nobody wants glitter flecks on their cheeks.