SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Functional Programming
Principles & Patterns
Agenda
● Introduction to Functional Programming
● Principles
● Concepts
● Patterns
● Q & A
Code-examples are written in Java and JavaScript
Introduction to Functional Programming
● Benefits
○ Declarative (what vs. how)
○ Scalability / Concurrency
○ Testability
○ Composability & Modularity
○ Ability to reason about programs / Simplicity
○ ...
○ In our case: Broadening our Horizon
● Use-cases
○ Mathematical programming
○ Distributed Systems
○ High Concurrency
○ GUI programming (new!)
○ ...
Functional Programming Languages
● Common Lisp
● Haskell
● SML
● Clojure
● Scala
● Erlang
● (Java)
● (JavaScript)
● ...
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Declarative vs. Imperative
● Defining WHAT to do vs. HOW to do it
● Expressive
● Improve / Optimize underlying algorithms
● Eliminate Side-effects as much as possible
Declarative vs. Imperative - Example
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Pure Functions
● No side-effects
● Referential Transparency (caching, ...)
● Thread-safe
● Compiler-Optimizations
● ...
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Higher Order Functions
● Critical concept in FP
● Functions can take functions as arguments
● Functions can return functions
● Enables functional composition
Higher Order Functions - Example #1
Higher Order Functions - Example #2
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Immutability
● Persistent Data Structures
● Every time a data structure would be mutated, a new one
is returned instead
● Simplifies state management and mutation tracking
● Enables optimizations
● Works well with pure functions
● Memory overhead is mitigated by sharing (Tries)
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Recursion
● Divide and Conquer
● Can provide elegant solutions for complex problems
● Not as complicated to do, if one knows how ;)
Recursion #1
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Laziness
● Evaluation is deferred to the last possible moment
● Avoids needless calculations
● Working with infinite data structures
● Works very well with declarative programming
Laziness Example
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
map / Filter / Reduce / Zip
● Backbone of functional programming
map
Filter
Reduce
Zip
Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
Currying
● Concept by Haskell Curry
● Translating a function that takes multiple arguments into
a sequence of functions which all take 1 argument
● e.g.: add(a, b) AND add(a)(b)
● Improves reusability and composition
● In some languages (Haskell, F#) functions are curried by
default
Currying - Example #1
Currying - Example #2
Currying - Example #3
Patterns
● GOF-Patterns in Functional Style
● Memoization
● Advanced Currying
● Immutability in practice
● Maybe / Optional
● Outlook: Advanced Topics
GOF Patterns vs. Functional Programming
GOF - Decorator (wrapper function)
GOF - Strategy (higher order functions)
Memoization (Caching Technique - Java)
Memoization (Caching Technique - JS)
Immutability in practice
● Data Structures don’t necessarily need to be persistent
in nature
● Use map / filter / reduce
● Examples in JS:
Maybe / Optional
● Pattern for handling absent (e.g.: Null) values
● Avoid annoying if (x==null) checks
● Great for declarative API’s
● Your business logic doesn’t need to deal with null
values, it can just use Maybe()’s
○ At the end, when the actual value is needed, the Maybe can be
evaluated and the null can be handled
Maybe / Optional
Advanced Topics
● Monoids / Functors / Applicatives
● Algebraic Structures in general
● Monads
● Transducers
● ...
Q & A
Resources #1
● https://vimeo.com/113588389
● http://looprecur.com/blog/
● https://www.youtube.com/playlist?list=PLK_hdtAJ4KqX0JOs_KMAmUNTNMRYhWEaC
● http://www.infoq.com/presentations/Simple-Made-Easy
● http://www.infoq.com/presentations/Clojure-Design-Patterns
● https://www.manning.com/books/functional-programming-in-java
● https://dzone.com/articles/functional-programming-java-8
● http://www.vasinov.com/blog/16-months-of-functional-programming/
● https://www.reddit.com/r/functionalprogramming/
● https://github.com/jhusain/learnrxjava/
● http://reactivex.io/learnrx/
● http://blog.jhades.org/java-8-how-to-use-optional/
Resources #2
● http://javascriptair.com/episodes/2015-12-30/
● http://www.amazon.de/Purely-Functional-Data-Structures-Okasaki/dp/0521663504/ref=sr_1_1?ie=UTF8&qid=1452875910&sr=8-1&k
eywords=functional+data+structures
● http://www.amazon.de/Functional-Thinking-Paradigm-Over-Syntax/dp/1449365515/ref=sr_1_1?ie=UTF8&qid=1452875871&sr=8-1&k
eywords=functional+thinking
● http://www.amazon.de/Becoming-Functional-Joshua-Backfield/dp/1449368174/ref=sr_1_1?ie=UTF8&qid=1452875879&sr=8-1&keyw
ords=becoming+functional
● http://www.amazon.de/Functional-JavaScript-Introducing-Programming-Underscore-js/dp/1449360726/ref=sr_1_1?ie=UTF8&qid=145
2875887&sr=8-1&keywords=functional+javascript
● https://github.com/MostlyAdequate/mostly-adequate-guide

Contenu connexe

Tendances

Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions Reem Alattas
 
String functions and operations
String functions and operations String functions and operations
String functions and operations Mudasir Syed
 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programmingAssaf Gannon
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variablessangrampatil81
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptxGDSCVJTI
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentationVibhor Grover
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooksMaulik Shah
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISPNilt1234
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2Thang Tran Duc
 
TDD and Unit Testing in Golang
TDD and Unit Testing in GolangTDD and Unit Testing in Golang
TDD and Unit Testing in GolangSofian Hadiwijaya
 
Jetpack Compose.pdf
Jetpack Compose.pdfJetpack Compose.pdf
Jetpack Compose.pdfSumirVats
 

Tendances (20)

React js
React jsReact js
React js
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
GraphQL
GraphQLGraphQL
GraphQL
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
JavaScript Functions
JavaScript Functions JavaScript Functions
JavaScript Functions
 
String functions and operations
String functions and operations String functions and operations
String functions and operations
 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programming
 
Scope rules : local and global variables
Scope rules : local and global variablesScope rules : local and global variables
Scope rules : local and global variables
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
OOP and FP
OOP and FPOOP and FP
OOP and FP
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 
Graphql presentation
Graphql presentationGraphql presentation
Graphql presentation
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2
 
TDD and Unit Testing in Golang
TDD and Unit Testing in GolangTDD and Unit Testing in Golang
TDD and Unit Testing in Golang
 
Jetpack Compose.pdf
Jetpack Compose.pdfJetpack Compose.pdf
Jetpack Compose.pdf
 

En vedette

Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Scott Wlaschin
 
Functional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataFunctional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataPaco Nathan
 
Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional ProgrammingAndreas Pauley
 
Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programmingnewmedio
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog3Pillar Global
 
那些 Functional Programming 教我的事
那些 Functional Programming 教我的事那些 Functional Programming 教我的事
那些 Functional Programming 教我的事Wen-Tien Chang
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming FundamentalsShahriar Hyder
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Scott Wlaschin
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 
Functional Reactive Programming in JavaScript
Functional Reactive Programming in JavaScriptFunctional Reactive Programming in JavaScript
Functional Reactive Programming in JavaScriptzupzup.org
 
Running Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic BeanstalkRunning Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic Beanstalkzupzup.org
 
Functional Programing
Functional ProgramingFunctional Programing
Functional ProgramingMax Arshinov
 
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.Oliver Kriska
 
Functional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic ProgrammerFunctional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic ProgrammerRaúl Raja Martínez
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigmskasenerd
 
Quality and Software Design Patterns
Quality and Software Design PatternsQuality and Software Design Patterns
Quality and Software Design PatternsPtidej Team
 
Describe professional programing languages and talks
Describe professional programing languages and talks Describe professional programing languages and talks
Describe professional programing languages and talks Ed Bray
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Lucidworks
 
Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Raja Hamid
 
Ruby language overview
Ruby language overviewRuby language overview
Ruby language overviewUptech
 

En vedette (20)

Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)
 
Functional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataFunctional programming for optimization problems in Big Data
Functional programming for optimization problems in Big Data
 
Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional Programming
 
Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programming
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog
 
那些 Functional Programming 教我的事
那些 Functional Programming 教我的事那些 Functional Programming 教我的事
那些 Functional Programming 教我的事
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Functional Reactive Programming in JavaScript
Functional Reactive Programming in JavaScriptFunctional Reactive Programming in JavaScript
Functional Reactive Programming in JavaScript
 
Running Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic BeanstalkRunning Containerized Node.js Services on AWS Elastic Beanstalk
Running Containerized Node.js Services on AWS Elastic Beanstalk
 
Functional Programing
Functional ProgramingFunctional Programing
Functional Programing
 
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
 
Functional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic ProgrammerFunctional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic Programmer
 
program development and paradigms
program development and paradigmsprogram development and paradigms
program development and paradigms
 
Quality and Software Design Patterns
Quality and Software Design PatternsQuality and Software Design Patterns
Quality and Software Design Patterns
 
Describe professional programing languages and talks
Describe professional programing languages and talks Describe professional programing languages and talks
Describe professional programing languages and talks
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
 
Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2Programming fundamentals lecture 1&2
Programming fundamentals lecture 1&2
 
Ruby language overview
Ruby language overviewRuby language overview
Ruby language overview
 

Similaire à Functional Programming Principles & Patterns

Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in RubyAlex Teut
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scaladatamantra
 
Advanced memory allocation
Advanced memory allocationAdvanced memory allocation
Advanced memory allocationJoris Bonnefoy
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programmingKonrad Szydlo
 
Reactive Software Systems
Reactive Software SystemsReactive Software Systems
Reactive Software SystemsBehrad Zari
 
Paper_An Efficient Garbage Collection in Java Virtual Machine via Swap I/O O...
Paper_An Efficient Garbage Collection in Java Virtual  Machine via Swap I/O O...Paper_An Efficient Garbage Collection in Java Virtual  Machine via Swap I/O O...
Paper_An Efficient Garbage Collection in Java Virtual Machine via Swap I/O O...Hyo jeong Lee
 
Improving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVMImproving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVMHolden Karau
 
The productivity brought by Clojure
The productivity brought by ClojureThe productivity brought by Clojure
The productivity brought by ClojureLaurence Chen
 
Winning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen ZhangWinning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen ZhangVivian S. Zhang
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytechyannick grenzinger
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katasGeorg Berky
 
Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextUnfold UI
 
Software Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationSoftware Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationHao Xu
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersHuffPost Code
 
Kotlin functional programming basic@Kotlin TW study group
Kotlin  functional programming basic@Kotlin TW study groupKotlin  functional programming basic@Kotlin TW study group
Kotlin functional programming basic@Kotlin TW study groupJulian Yu-Lang Chu
 
A super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMA super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMHolden Karau
 

Similaire à Functional Programming Principles & Patterns (20)

Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in Ruby
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Advanced memory allocation
Advanced memory allocationAdvanced memory allocation
Advanced memory allocation
 
Memory in go
Memory in goMemory in go
Memory in go
 
Progress_190213
Progress_190213Progress_190213
Progress_190213
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
Reactive Software Systems
Reactive Software SystemsReactive Software Systems
Reactive Software Systems
 
Paper_An Efficient Garbage Collection in Java Virtual Machine via Swap I/O O...
Paper_An Efficient Garbage Collection in Java Virtual  Machine via Swap I/O O...Paper_An Efficient Garbage Collection in Java Virtual  Machine via Swap I/O O...
Paper_An Efficient Garbage Collection in Java Virtual Machine via Swap I/O O...
 
Improving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVMImproving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVM
 
Introduction to Functional programming
Introduction to Functional programmingIntroduction to Functional programming
Introduction to Functional programming
 
The productivity brought by Clojure
The productivity brought by ClojureThe productivity brought by Clojure
The productivity brought by Clojure
 
Winning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen ZhangWinning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen Zhang
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
SOLID refactoring - racing car katas
SOLID refactoring - racing car katasSOLID refactoring - racing car katas
SOLID refactoring - racing car katas
 
Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNext
 
Software Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale AutomationSoftware Design Practices for Large-Scale Automation
Software Design Practices for Large-Scale Automation
 
Progress_190130
Progress_190130Progress_190130
Progress_190130
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 
Kotlin functional programming basic@Kotlin TW study group
Kotlin  functional programming basic@Kotlin TW study groupKotlin  functional programming basic@Kotlin TW study group
Kotlin functional programming basic@Kotlin TW study group
 
A super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMA super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAM
 

Dernier

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Dernier (20)

Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

Functional Programming Principles & Patterns

  • 2. Agenda ● Introduction to Functional Programming ● Principles ● Concepts ● Patterns ● Q & A Code-examples are written in Java and JavaScript
  • 3. Introduction to Functional Programming ● Benefits ○ Declarative (what vs. how) ○ Scalability / Concurrency ○ Testability ○ Composability & Modularity ○ Ability to reason about programs / Simplicity ○ ... ○ In our case: Broadening our Horizon ● Use-cases ○ Mathematical programming ○ Distributed Systems ○ High Concurrency ○ GUI programming (new!) ○ ...
  • 4. Functional Programming Languages ● Common Lisp ● Haskell ● SML ● Clojure ● Scala ● Erlang ● (Java) ● (JavaScript) ● ...
  • 5. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 6. Declarative vs. Imperative ● Defining WHAT to do vs. HOW to do it ● Expressive ● Improve / Optimize underlying algorithms ● Eliminate Side-effects as much as possible
  • 8. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 9. Pure Functions ● No side-effects ● Referential Transparency (caching, ...) ● Thread-safe ● Compiler-Optimizations ● ...
  • 10. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 11. Higher Order Functions ● Critical concept in FP ● Functions can take functions as arguments ● Functions can return functions ● Enables functional composition
  • 12. Higher Order Functions - Example #1
  • 13. Higher Order Functions - Example #2
  • 14. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 15. Immutability ● Persistent Data Structures ● Every time a data structure would be mutated, a new one is returned instead ● Simplifies state management and mutation tracking ● Enables optimizations ● Works well with pure functions ● Memory overhead is mitigated by sharing (Tries)
  • 16. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 17. Recursion ● Divide and Conquer ● Can provide elegant solutions for complex problems ● Not as complicated to do, if one knows how ;)
  • 19. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 20. Laziness ● Evaluation is deferred to the last possible moment ● Avoids needless calculations ● Working with infinite data structures ● Works very well with declarative programming
  • 22. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 23. map / Filter / Reduce / Zip ● Backbone of functional programming
  • 24. map
  • 27. Zip
  • 28. Concepts ● Declarative vs. Imperative ● Pure Functions ● Higher Order Functions (+Lambdas) ● Immutability ● Recursion ● Laziness ● map/filter/reduce/zip/flatMap ● Currying
  • 29. Currying ● Concept by Haskell Curry ● Translating a function that takes multiple arguments into a sequence of functions which all take 1 argument ● e.g.: add(a, b) AND add(a)(b) ● Improves reusability and composition ● In some languages (Haskell, F#) functions are curried by default
  • 33. Patterns ● GOF-Patterns in Functional Style ● Memoization ● Advanced Currying ● Immutability in practice ● Maybe / Optional ● Outlook: Advanced Topics
  • 34. GOF Patterns vs. Functional Programming
  • 35. GOF - Decorator (wrapper function)
  • 36. GOF - Strategy (higher order functions)
  • 39. Immutability in practice ● Data Structures don’t necessarily need to be persistent in nature ● Use map / filter / reduce ● Examples in JS:
  • 40. Maybe / Optional ● Pattern for handling absent (e.g.: Null) values ● Avoid annoying if (x==null) checks ● Great for declarative API’s ● Your business logic doesn’t need to deal with null values, it can just use Maybe()’s ○ At the end, when the actual value is needed, the Maybe can be evaluated and the null can be handled
  • 42. Advanced Topics ● Monoids / Functors / Applicatives ● Algebraic Structures in general ● Monads ● Transducers ● ...
  • 43. Q & A
  • 44.
  • 45. Resources #1 ● https://vimeo.com/113588389 ● http://looprecur.com/blog/ ● https://www.youtube.com/playlist?list=PLK_hdtAJ4KqX0JOs_KMAmUNTNMRYhWEaC ● http://www.infoq.com/presentations/Simple-Made-Easy ● http://www.infoq.com/presentations/Clojure-Design-Patterns ● https://www.manning.com/books/functional-programming-in-java ● https://dzone.com/articles/functional-programming-java-8 ● http://www.vasinov.com/blog/16-months-of-functional-programming/ ● https://www.reddit.com/r/functionalprogramming/ ● https://github.com/jhusain/learnrxjava/ ● http://reactivex.io/learnrx/ ● http://blog.jhades.org/java-8-how-to-use-optional/
  • 46. Resources #2 ● http://javascriptair.com/episodes/2015-12-30/ ● http://www.amazon.de/Purely-Functional-Data-Structures-Okasaki/dp/0521663504/ref=sr_1_1?ie=UTF8&qid=1452875910&sr=8-1&k eywords=functional+data+structures ● http://www.amazon.de/Functional-Thinking-Paradigm-Over-Syntax/dp/1449365515/ref=sr_1_1?ie=UTF8&qid=1452875871&sr=8-1&k eywords=functional+thinking ● http://www.amazon.de/Becoming-Functional-Joshua-Backfield/dp/1449368174/ref=sr_1_1?ie=UTF8&qid=1452875879&sr=8-1&keyw ords=becoming+functional ● http://www.amazon.de/Functional-JavaScript-Introducing-Programming-Underscore-js/dp/1449360726/ref=sr_1_1?ie=UTF8&qid=145 2875887&sr=8-1&keywords=functional+javascript ● https://github.com/MostlyAdequate/mostly-adequate-guide