Composition
Functional Programming in JavaScript
JavaScript functional programming intro
funcational programming
funcational programming
why?
more TESTable & Bug FREE (DESBUG)
SELF-DOCUMENTing
funcational programming
CORE
+ first class function
+ pure function
+ curry
+ compose
Intro
Imperative &
Declarative
Imperative
Declarative
Focusing on statements that change program
state
by
telling computer how to do that.
Describing what you're trying to achieve
, without instructing how to do it.
paradigms
Imperative
paradigms
Imperative
Imperative
DECLARATIVE
paradigms
Haskell, F#, Lisp
Declarative
Declarative
First Class Function
treat function like a normal data type.
Fundamental
FUNCTION CAN BE PASSED AS A DATA.
refs: https://stackoverflow.com/questions/705173/what-is-meant-by-first-class-object?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
First Class Function
Fundamental
CONSTRUCTING NEW FUNCTIONS DURING THE EXECUTION OF A PROGRAM.
STORING THEM IN DATA STRUCTURES
PASSING THEM AS ARGUMENTS TO OTHER FUNCTIONS
RETURNING THEM AS THE VALUES OF OTHER FUNCTIONS
NO SIDE EFFECTS (MUTATIONS, QUERYING THE DOM ...)
ALWAYS RETURNS THE SAME RESULT IF THE SAME ARGUMENTS ARE PASSED IN.
PURE FUNCTION
Fundamental
+ Cacheable
+ Portable / Self-Documenting
+ Testable
+ Reasonable
PURE FUNCTION
Fundamental
PURE FUNCTION
Fundamental
PURE
impure
PURE FUNCTION
Fundamental
impure (OOP)
keep state to object self and send/receive
Messages
Cacheable
https://codepen.io/guAnsunyata/pen/zWQNxq?editors=0012
PURE FUNCTION
Fundamental
Portable
PURE FUNCTION
Fundamental
ref without external state
Redux - Reducer
Time Control /
EVENT SOURCING
PURE FUNCTION
Fundamental
CURRY
Fundamental
FUNCTION RETURNS A FUNCTION THAT TAKES THE REMAINING ARGUMENTS
CURRY
Fundamental
Ramda
CURRY
Fundamental
(husbandry)
https://drboolean.gitbooks.io/mostly-adequate-guide-old/content/ch5.html#functional-husbandry
COMPOSITE
Fundamental
"love is never having to say you're sorry"
pointfree is never having to say your data
COMPOSITE
Fundamental
FIRST CLASS FUNCTIONS, CURRYING, AND COMPOSITION ALL PLAY WELL TOGETHER TO CREATE THIS STYLE.
POINTFREE
POINTFREE
COMPOSITE
Fundamental
https://medium.freecodecamp.org/elegant-patterns-in-modern-javascript-roro-be01e7669cbd
PIPE
PIPE
EXAMPLE IN ML PROJECT
Next?
Thanks
Made with Slides.com