Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TDC2016SP - Trilha Programação Funcional

184 views

Published on

Impactos no design com o uso de programação funcional

Published in: Education
  • Be the first to comment

TDC2016SP - Trilha Programação Funcional

  1. 1. Globalcode – Open4education Impactos no design utilizando programação funcional Luiz Costa gutomcosta@gmail.com / @gutomcosta
  2. 2. twitter.com/gutomcosta github.com/gutomcosta www.sagadoprogamador.com.br medium.com/saga-do-programador
  3. 3. orientação a objetos
  4. 4. conjunto de ideias encapsulamento polimorfismo objetos herança estado ...
  5. 5. programação funcional
  6. 6. conjunto de ideias funções higher-order functions imutabilidade lazy evaluation recursão ...
  7. 7. Dois estilos de escrita
  8. 8. código imperativo Foco no “como fazer”
  9. 9. código declarativo Foco no “o que fazer”
  10. 10. código declarativo Foco no “o que fazer”
  11. 11. “When writing a modular program to solve a problem, one first divides the problem into subproblems, then solves the subproblems, and finally combines the solutions. The ways in which one can divide up the original problem depend directly on the ways in which one can glue solutions together.” “Why functional programming matters” -John Hughes in Research topics in functional programming, 1990
  12. 12. “When writing a modular program to solve a problem, one first divides the problem into subproblems, then solves the subproblems, and finally combines the solutions. The ways in which one can divide up the original problem depend directly on the ways in which one can glue solutions together.” “Why functional programming matters” -John Hughes in Research topics in functional programming, 1990
  13. 13. “When writing a modular program to solve a problem, one first divides the problem into subproblems, then solves the subproblems, and finally combines the solutions. The ways in which one can divide up the original problem depend directly on the ways in which one can glue solutions together.” “Why functional programming matters” -John Hughes in Research topics in functional programming, 1990
  14. 14. ..argue in the remainder of this paper that functional languages provide two new, very important kinds of glue. “Why functional programming matters” -John Hughes in Research topics in functional programming, 1990 higher order function lazy evaluation
  15. 15. building blocks
  16. 16. first class functions uma variável?
  17. 17. invocando uma função função como parâmetro
  18. 18. invoca a função
  19. 19. mesma função variando comportamento dados e funções separados
  20. 20. higher order function uma funcão que recebe outra função como argumento ou retorna uma função
  21. 21. Como First Class Functions e Higher Order Functions podem impactar nas decisões de design?
  22. 22. OO foco na estrutura Como substituir uma implementação em runtime?
  23. 23. FP foco na transformação transformação?
  24. 24. listas, map, reduce, filter
  25. 25. map capitalize capitalize capitalize Jose Paulo Luiz jose luizpaulo TextTextTextText clojure.string
  26. 26. focus on results, not steps “Functional Thinking” -Neal Ford - IBM Developer Works series
  27. 27. Filter clojure.string 1 2 3 4 5 6 7 8 9
  28. 28. Argentum Análise de Candlesticks, bolsa de valores
  29. 29. Candlesticks
  30. 30. Argentum Domain Model
  31. 31. como representar os conceitos? Negócio, Candlestick
  32. 32. define uma abstração
  33. 33. dados e funções separados
  34. 34. decompose an algorithm into functions that are simple, meaningful and useful. “Tutorial on Good Lisp Programming Style” -Peter Norvig in 1992
  35. 35. decompose an algorithm into functions that are simple, meaningful and useful. “Tutorial on Good Lisp Programming Style” -Peter Norvig in 1992
  36. 36. decomposição invariantes
  37. 37. decomposição dependência de outro namespace
  38. 38. Argentum Geração de gráfico com indicadores define uma abstração define comportamentos diferentes
  39. 39. como variar o comportamento?
  40. 40. declara as funções
  41. 41. compondo funções higher order functions decomposição de função
  42. 42. calculando a média móvel
  43. 43. com diferentes building blocks, é preciso repensar as decisões de design
  44. 44. OO e FP Juntos?
  45. 45. Functional in the small, OO in the large. “Tell Above, and Ask Below - Hybridizing OO and Functional design” -Michael Feathers, blog post
  46. 46. Functional Core, imperative shell. “Destroy all software - episode 72” -Gary Bernhardt, destroy on software screen cast series
  47. 47. conclusão
  48. 48. Functional Programming is more a mindset than a particular set of tools or languages. “Functional Thinking” -Neal Ford - IBM Developer Works series
  49. 49. Obrigado
  50. 50. Referências SICP - http://mitpress.mit.edu/sicp/full-text/book/book.html Why functional programming matters - http://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf Clojure - http://clojure.org/ Functional Thinking - http://www.ibm.com/developerworks/java/library/j-ft1/index.html Tell Above, and ask Below - http://michaelfeathers.typepad.com/michael_feathers_blog/2012/03/ tell-above-and-ask-below-hybridizing-oo-and-functional-design.html Functional Core, imperative shell - https://www.destroyallsoftware.com/screencasts/catalog/ functional-core-imperative-shell Tutorial on good lisp programming style - http://www.cs.umd.edu/~nau/cmsc421/norvig-lisp- style.pdf

×