painful. It’s about making things easier for our teammates. It’s about getting things wrong and being able to recover. It’s about forming good habits. It’s about understanding your toolset. Pragmatic Programmer
large JavaScript project where the now lead developer has started heavily using functional programming throughout the code base, but to a level that makes it hard to work in. I'll give you an example - essentially he will try to never write an if statement (e.g. will create a function like "throwIf"), never write a loop, never declare variables, chain everything into massive pipe and compose functions.
support additional functionality? Reusability Is there a lot of duplication? Easy to reason about Is my code unstructured and hard to follow? Easy to modularize If I change one file, is another file affected? Testability Do I struggle to unit test my functions?
return the same output. Produces no side effects. In the case of a mutable state, two calls of the same function can potentially produce two different results.
in a program, without actually changing the final result of the program. Any piece of code that mutates variables, objects, or data structures outside of a function are not referentially transparent. The benefit is that it eliminates side-effects from your code.
excessively deep or infinite recursion, in which a function calls itself so many times that the space needed to store the variables and information associated with each call is more than can fit on the stack.
multiple processors at once because of the interdependencies between data. In pure functional programming languages the computer can run two (or many more) functions at once because those functions are not altering outside state information.
from imperative programming background. Recursion is very expensive to use, It has a high cost in terms of memory. Terminology: curry, pure functions, referential transparency. Pure functions: combining them into a complete application is very hard. 01 02 03 04
by Flaticon, and infographics & images by Freepik. THANKS! Do you have any questions? [email protected] pebmed.com.br Please keep this slide for attribution.