GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
FP libraries for handling complex data
1. FP libraries for handling complex
data
Daniel Alarcón Amador – Passionate People
2. What is Functional Programming
“FP is a programming paradigm—a style of building the structure and
elements of computer programs—that treats computation as the
evaluation of mathematical functions and avoids changing-state and
mutable data.” - Wikipedia
3. Why do we use it?
Immutability
Reusability
Cleaner code
Purity
Bye bye side effects
To be as cool as Dan Abramov (creator from Redux)
4. How does it work?
FP approach
Regular approach, with mutation
11. Ramda
Ramda emphasizes a purer functional style.
Immutability and side-effect free functions are
at the heart of its design philosophy.
Ramda functions are automatically curried.
This allows you to easily build up new
functions from old ones simply by not
supplying the final parameters.
The parameters to Ramda functions are
arranged to make it convenient for currying.
The data to be operated on is generally
supplied last.
17. Example 1 – Radio feed
We have a page that will recommend a list of radio stations depending of:
How trendy the radio is
Order Id supplied via the Back End
The suitable age of the radio station based in the user
18. Example 2 – Make an Inbox
The Back End sends you all the emails for one user
Separate them into categories: Primary, social and promotions
Filter the spam based in a “Spam Words” list.
The emails need to be ordered by date.
19. Example 3 - Spotify
The Back End sends you a list of songs and related albums
Make a list with the artist based in the songs received
Every artist needs to have their albums with their songs in it.
Some songs are not available in all the countries. Filter by [‘NL’, ‘USA’], etc.
The wildcard ‘*’ means that the song is available for all the countries.
Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functional programming is declarative rather than imperative, and application state flows through pure functions. Contrast with object oriented programming, where application state is usually shared and colocated with methods in objects.