SlideShare uma empresa Scribd logo
1 de 109
Solving behavioral
complexity with FRP
Oleksii Levzhynskyi
Grammarly
• Web Editor
• Desktop Editor
• Web Extension (past)
• @grammarly/focal contributor
Oleksii Levzhynskyi
Chapter #1
Complexity.
Email validation
((([t ]*rn)?[t ]+)?[-!#-'*+/-9=?A-Z^-
~]+(.[-!#-'*+/-9=?A-Z^-~]+)*(([t
]*rn)?[t ]+)?|(([t ]*rn)?[t ]+)?"(((([t
]*rn)?[t ]+)?([]!#-[^-~]|([t -~])))+(([t
]*rn)?[t ]+)?|(([t ]*rn)?[t ]+)?)"(([t
]*rn)?[t ]+)?)@((([t ]*rn)?[t ]+)?[-!#-
'*+/-9=?A-Z^-~]+(.[-!#-'*+/-9=?A-Z^-
~]+)*(([t ]*rn)?[t ]+)?|(([t ]*rn)?[t
]+)?[((([t ]*rn)?[t ]+)?[!-Z^-~])*(([t
]*rn)?[t ]+)?](([t ]*rn)?[t ]+)?)
RFC 5322
99%
Where it comes from
Where it comes from
• => Historically - “front-end is simple”
Where it comes from
• Historically - “front-end is simple”
• => Incomplete requirements
Where it comes from
• Historically - “front-end is simple”
• Incomplete requirements
• => 3rd parties that force different approaches
Where it comes from
• Historically - “front-end is simple”
• Incomplete requirements
• 3rd parties that force different approaches
• => “Small” changes on the middle of development
Where it comes from
• Historically - “front-end is simple”
• Incomplete requirements
• 3rd parties that force different approaches
• “Small” changes on the middle of development
• => It just complex
Where it comes from
• Historically - “front-end is simple”
• Incomplete requirements
• 3rd parties that force different approaches
• “Small” changes on the middle of development
• It just complex
• => …
How to detect complexity
How to detect complexity
• => Challenge requirements
How to detect complexity
• Challenge requirements
• => Talk with colleagues
How to detect complexity
• Challenge requirements
• Talk with colleagues
• => Architecture design sessions
How to detect complexity
• Challenge requirements
• Talk with colleagues
• Architecture design sessions
• => Prototyping
What we are looking for?
Structural complexity
https://bit.ly/2u9LsUb
Coupling & Cohesion
Behavioral complexity
Behavioral complexity
Product / Requirements
Async
How to deal
• => Callbacks
How to deal
• => Callback hell
How to deal
• Callback hell
• => Promise
How to deal
• Callback hell
• Promise
• => Event emitter
How to deal
• Callback hell
• Promise
• Event emitter
• => Flux/Redux
RP
“Manages asynchronous data flows between sources of
data and components that need to react to that data.”
RP
RP + FP
Deal with async data streams in a functional way:
• => pure function
RP + FP
Deal with async data streams in a functional way:
• pure function
• => immutable data
RP + FP
Deal with async data streams in a functional way:
• pure function
• immutable data
• => composability
RP + FP
Deal with async data streams in a functional way:
• pure function
• immutable data
• composability
+
FRP
“It’s a different way of thinking: the program is expressed
as a reaction to its inputs, or as a flow of data.”
Stephen Blackheath, Anthony Jones.
“Functional Reactive Programming.”
1. Events
2. Behaviors
3. Composition and Transformation
Chapter #2
Real life example
Cards List
Todo
• => Cards list
• Active card
• Animate active card
• Animate cards positions
• Optimization
Component #3
Component #1
Component #2
CardList
Component #3
Component #1
Component #2
Card #3
Card #3
Observable<Card[]>
Too wordy…
F.div = div + observable props
Atom = Behavior
Atom = Behavior
Atom<ReadonlyArray<Card>>
=>
Atom<ReadonlyArray<Atom<Card>>>
ViewModel
Card #3
SortedMap<CardId, Card>
Cards List
• [Done] Cards list
• => Active card
• Animate active card
• Animate cards positions
• Optimization
State + activeCard
undefined?
Idiomatic handling for empty values
Idiomatic handling for empty values
Use pure functions!
Cards List
• [Done] Cards list
• [Done] Active card
• => Animate active card
• Animate cards positions
• Optimization
Animate it
<CardAnimation />
<CardAnimation />
Cards List
• [Done] Cards list
• [Done] Active card
• [Done] Animate active card
• => Animate cards positions
• Optimization
position: absolute
top: <N>px
transition-property: top
position: absolute
top: <N>px
transform: translateY(<N>px)
transition-property: transform
Composition
Cards List
• [Done] Cards list
• [Done] Active card
• [Done] Animate active card
• [Done] Animate cards positions
• => Optimization
Interfaces
ResizeObserver
‘scroll’
+
Interfaces
Cards List
• [Done] Cards list
• [Done] Active card
• [Done] Animate active card
• [Done] Animate cards positions
• [Done] Optimization
Tips
#1 The complexity - is ok
#2 Think about complexity in advance
#3 Expect async
#4 Try FRP to solve it
#4 Try FRP to solve it
Further reading
• Reactive manifesto - https://www.reactivemanifesto.org
• The complexity trap - https://danielwestheide.com/blog/2018/12/07/the-complexity-
trap.html
• A quick introduction into FRP - https://medium.freecodecamp.org/functional-
reactive-programming-frp-imperative-vs-declarative-vs-reactive-style-84878272c77f
• Functional Reactive Programming, Stephen Blackheath and Anthony Jones
• Professor frisby's mostly adequate guide to functional programming
• https://github.com/gcanti/fp-ts
The End

Mais conteúdo relacionado

Semelhante a Oleksii Levzhynskyi "Solving behavioral complexity with FRP"

Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
SonaCharles2
 

Semelhante a Oleksii Levzhynskyi "Solving behavioral complexity with FRP" (20)

React Native Performance
React Native Performance React Native Performance
React Native Performance
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
 
The Fuss about || Haskell | Scala | F# ||
The Fuss about || Haskell | Scala | F# ||The Fuss about || Haskell | Scala | F# ||
The Fuss about || Haskell | Scala | F# ||
 
What the f is a monad?
What the f is a monad?What the f is a monad?
What the f is a monad?
 
Getting your hands on graphs
Getting your hands on graphsGetting your hands on graphs
Getting your hands on graphs
 
2 Years of Real World FP at REA
2 Years of Real World FP at REA2 Years of Real World FP at REA
2 Years of Real World FP at REA
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
Om nom nom nom
Om nom nom nomOm nom nom nom
Om nom nom nom
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014
 
Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)Ruby and rails - Advanced Training (Cybage)
Ruby and rails - Advanced Training (Cybage)
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
 
Grokking Techtalk #37: Data intensive problem
 Grokking Techtalk #37: Data intensive problem Grokking Techtalk #37: Data intensive problem
Grokking Techtalk #37: Data intensive problem
 
Wrapper Generation Supervised by a Noisy Crowd
Wrapper Generation Supervised by a Noisy CrowdWrapper Generation Supervised by a Noisy Crowd
Wrapper Generation Supervised by a Noisy Crowd
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
Better Data Management using TaffyDB
Better Data Management using TaffyDBBetter Data Management using TaffyDB
Better Data Management using TaffyDB
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 

Mais de Fwdays

Mais de Fwdays (20)

"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y..."How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
"How Preply reduced ML model development time from 1 month to 1 day",Yevhen Y...
 
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
"GenAI Apps: Our Journey from Ideas to Production Excellence",Danil Topchii
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets"What is a RAG system and how to build it",Dmytro Spodarets
"What is a RAG system and how to build it",Dmytro Spodarets
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi"Distributed graphs and microservices in Prom.ua",  Maksym Kindritskyi
"Distributed graphs and microservices in Prom.ua", Maksym Kindritskyi
 
"Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl..."Rethinking the existing data loading and processing process as an ETL exampl...
"Rethinking the existing data loading and processing process as an ETL exampl...
 
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T..."How Ukrainian IT specialist can go on vacation abroad without crossing the T...
"How Ukrainian IT specialist can go on vacation abroad without crossing the T...
 
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ..."The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
"The Strength of Being Vulnerable: the experience from CIA, Tesla and Uber", ...
 
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu..."[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
"[QUICK TALK] Radical candor: how to achieve results faster thanks to a cultu...
 
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care..."[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
"[QUICK TALK] PDP Plan, the only one door to raise your salary and boost care...
 
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"..."4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
"4 horsemen of the apocalypse of working relationships (+ antidotes to them)"...
 
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast..."Reconnecting with Purpose: Rediscovering Job Interest after Burnout",  Anast...
"Reconnecting with Purpose: Rediscovering Job Interest after Burnout", Anast...
 
"Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others..."Mentoring 101: How to effectively invest experience in the success of others...
"Mentoring 101: How to effectively invest experience in the success of others...
 
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova"Mission (im) possible: How to get an offer in 2024?",  Oleksandra Myronova
"Mission (im) possible: How to get an offer in 2024?", Oleksandra Myronova
 
"Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv..."Why have we learned how to package products, but not how to 'package ourselv...
"Why have we learned how to package products, but not how to 'package ourselv...
 
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin..."How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
"How to tame the dragon, or leadership with imposter syndrome", Oleksandr Zin...
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Oleksii Levzhynskyi "Solving behavioral complexity with FRP"

Notas do Editor

  1. Поведенческая сложность возникает в момент взаимодействия модулей, но не когда вы читаете код, а когда они начинают посылать друг другу сообщения в рантайме.