際際滷

際際滷Share a Scribd company logo
Functional
Approach to
Software
Engineering
Pasindu Perera
@udnisap
Outline
- Pure functions
- Shared Mutable State
- Null
- Monads
- Example use cases in JavaScript
Pure Functions  No Mutations
 No Side effects
Function
Input
Output
Function
Input
Return Exceptions
Shared Mutable
State
Shared Mutable
State
No difference between the value
and the reference to a piece of
data
Referential
Transparency
This is not referential transparency
Null
Maybe Null
Monads
Monads
In simple terms
-- supports Map
obj.map(f).map(g) == obj.map(g~f)
-- pointed -- A way to lift values
Containers with functionality that supports
associativity and identity
 Arrays
 Promises
 And much more
Examples

https://goo.gl/nRdFQX

More Related Content

Functional Approach to Software Engineering

Editor's Notes

  • #2: https://jsbin.com/cihapuf/edit?js,output
  • #7: There are two ways to get a value out of a function -- Return path -- Exception path
  • #9: Javascript is safe in most of the cases since it is single threaded. Think of this in Java terms Mutual exclusions Dead locks / Starvation Even in Javascript if you have concurrent browser tabs accessing network or local storage
  • #15: Most of these act like Monads.