Slide 1

Slide 1 text

impactos no design com programação funcional Luiz Costa @gutomcosta www.sagadoprogramador.com.br Sunday, October 20, 13

Slide 2

Slide 2 text

Sunday, October 20, 13

Slide 3

Slide 3 text

Programação Funcional? Sunday, October 20, 13

Slide 4

Slide 4 text

Programação Funcional? Sunday, October 20, 13

Slide 5

Slide 5 text

Programação Funcional? Sunday, October 20, 13

Slide 6

Slide 6 text

Programação Funcional? Sunday, October 20, 13

Slide 7

Slide 7 text

Programação Funcional? Sunday, October 20, 13

Slide 8

Slide 8 text

Programação Funcional? e alguns novatos Sunday, October 20, 13

Slide 9

Slide 9 text

orientação a objetos Sunday, October 20, 13

Slide 10

Slide 10 text

Sunday, October 20, 13

Slide 11

Slide 11 text

conjunto de ideias Sunday, October 20, 13

Slide 12

Slide 12 text

conjunto de ideias encapsulamento polimorfismo objetos herança estado ... Sunday, October 20, 13

Slide 13

Slide 13 text

programação funcional Sunday, October 20, 13

Slide 14

Slide 14 text

Sunday, October 20, 13

Slide 15

Slide 15 text

conjunto de ideias Sunday, October 20, 13

Slide 16

Slide 16 text

conjunto de ideias funções higher-order functions imutabilidade lazy evaluation recursão ... Sunday, October 20, 13

Slide 17

Slide 17 text

código imperativo Sunday, October 20, 13

Slide 18

Slide 18 text

código imperativo Sunday, October 20, 13

Slide 19

Slide 19 text

código imperativo Sunday, October 20, 13

Slide 20

Slide 20 text

código imperativo Sunday, October 20, 13

Slide 21

Slide 21 text

código imperativo Foco no “como fazer” Sunday, October 20, 13

Slide 22

Slide 22 text

código declarativo Sunday, October 20, 13

Slide 23

Slide 23 text

código declarativo Foco no “o que fazer” Sunday, October 20, 13

Slide 24

Slide 24 text

código declarativo Sunday, October 20, 13

Slide 25

Slide 25 text

código declarativo Foco no “o que fazer” Sunday, October 20, 13

Slide 26

Slide 26 text

“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 Sunday, October 20, 13

Slide 27

Slide 27 text

“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 Sunday, October 20, 13

Slide 28

Slide 28 text

“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 Sunday, October 20, 13

Slide 29

Slide 29 text

..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 Sunday, October 20, 13

Slide 30

Slide 30 text

building blocks Sunday, October 20, 13

Slide 31

Slide 31 text

Sunday, October 20, 13

Slide 32

Slide 32 text

uma variável? Sunday, October 20, 13

Slide 33

Slide 33 text

first class functions uma variável? Sunday, October 20, 13

Slide 34

Slide 34 text

Sunday, October 20, 13

Slide 35

Slide 35 text

invocando uma função função como parâmetro Sunday, October 20, 13

Slide 36

Slide 36 text

invoca a função Sunday, October 20, 13

Slide 37

Slide 37 text

Sunday, October 20, 13

Slide 38

Slide 38 text

dados e funções separados Sunday, October 20, 13

Slide 39

Slide 39 text

mesma função variando comportamento dados e funções separados Sunday, October 20, 13

Slide 40

Slide 40 text

higher order function uma funcão que recebe outra função como argumento ou retorna uma função Sunday, October 20, 13

Slide 41

Slide 41 text

functional style Sunday, October 20, 13

Slide 42

Slide 42 text

OO foco na estrutura Como substituir uma implementação em runtime? Sunday, October 20, 13

Slide 43

Slide 43 text

FP foco na transformação transformação? Sunday, October 20, 13

Slide 44

Slide 44 text

listas, map, reduce, filter Sunday, October 20, 13

Slide 45

Slide 45 text

map Text Text Text Text Sunday, October 20, 13

Slide 46

Slide 46 text

map Text Text Text Text clojure.string Sunday, October 20, 13

Slide 47

Slide 47 text

map jose luiz paulo Text Text Text Text clojure.string Sunday, October 20, 13

Slide 48

Slide 48 text

map capitalize Jose jose luiz paulo Text Text Text Text clojure.string Sunday, October 20, 13

Slide 49

Slide 49 text

map capitalize capitalize Jose Paulo jose luiz paulo Text Text Text Text clojure.string Sunday, October 20, 13

Slide 50

Slide 50 text

map capitalize capitalize capitalize Jose Paulo Luiz jose luiz paulo Text Text Text Text clojure.string Sunday, October 20, 13

Slide 51

Slide 51 text

focus on results, not steps “Functional Thinking” -Neal Ford - IBM Developer Works series Sunday, October 20, 13

Slide 52

Slide 52 text

Filter clojure.string Sunday, October 20, 13

Slide 53

Slide 53 text

Filter clojure.string Sunday, October 20, 13

Slide 54

Slide 54 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 55

Slide 55 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 56

Slide 56 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 57

Slide 57 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 58

Slide 58 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 59

Slide 59 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 60

Slide 60 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 61

Slide 61 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 62

Slide 62 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 63

Slide 63 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 64

Slide 64 text

Filter clojure.string 1 2 3 4 5 6 7 8 9 Sunday, October 20, 13

Slide 65

Slide 65 text

Reduce 10 20 30 40 0 Sunday, October 20, 13

Slide 66

Slide 66 text

Reduce 10 20 30 40 0 função Sunday, October 20, 13

Slide 67

Slide 67 text

Reduce 100 função Sunday, October 20, 13

Slide 68

Slide 68 text

Argentum Análise de Candlesticks, bolsa de valores Sunday, October 20, 13

Slide 69

Slide 69 text

Candlesticks Sunday, October 20, 13

Slide 70

Slide 70 text

Argentum Domain Model Sunday, October 20, 13

Slide 71

Slide 71 text

antes, um pouco de clojure muito pouco mesmo ... Sunday, October 20, 13

Slide 72

Slide 72 text

Clojure Sunday, October 20, 13

Slide 73

Slide 73 text

Clojure Sunday, October 20, 13

Slide 74

Slide 74 text

Clojure Sunday, October 20, 13

Slide 75

Slide 75 text

Clojure Sunday, October 20, 13

Slide 76

Slide 76 text

Clojure Sunday, October 20, 13

Slide 77

Slide 77 text

Clojure Sunday, October 20, 13

Slide 78

Slide 78 text

como representar os conceitos? Negócio, Candlestick Sunday, October 20, 13

Slide 79

Slide 79 text

Sunday, October 20, 13

Slide 80

Slide 80 text

Sunday, October 20, 13

Slide 81

Slide 81 text

Sunday, October 20, 13

Slide 82

Slide 82 text

define uma abstração Sunday, October 20, 13

Slide 83

Slide 83 text

Sunday, October 20, 13

Slide 84

Slide 84 text

dados e funções separados Sunday, October 20, 13

Slide 85

Slide 85 text

dados e funções separados Sunday, October 20, 13

Slide 86

Slide 86 text

decompose an algorithm into functions that are simple, meaningful and useful. “Tutorial on Good Lisp Programming Style” -Peter Norvig in 1992 Sunday, October 20, 13

Slide 87

Slide 87 text

decompose an algorithm into functions that are simple, meaningful and useful. “Tutorial on Good Lisp Programming Style” -Peter Norvig in 1992 Sunday, October 20, 13

Slide 88

Slide 88 text

decomposição Sunday, October 20, 13

Slide 89

Slide 89 text

decomposição Sunday, October 20, 13

Slide 90

Slide 90 text

decomposição invariantes Sunday, October 20, 13

Slide 91

Slide 91 text

decomposição Sunday, October 20, 13

Slide 92

Slide 92 text

decomposição Sunday, October 20, 13

Slide 93

Slide 93 text

decomposição Sunday, October 20, 13

Slide 94

Slide 94 text

decomposição Sunday, October 20, 13

Slide 95

Slide 95 text

decomposição dependência de outro namespace Sunday, October 20, 13

Slide 96

Slide 96 text

Argentum Geração de gráfico com indicadores Sunday, October 20, 13

Slide 97

Slide 97 text

Argentum Geração de gráfico com indicadores define uma abstração Sunday, October 20, 13

Slide 98

Slide 98 text

Argentum Geração de gráfico com indicadores define uma abstração define comportamentos diferentes Sunday, October 20, 13

Slide 99

Slide 99 text

como variar o comportamento? Sunday, October 20, 13

Slide 100

Slide 100 text

declara as funções Sunday, October 20, 13

Slide 101

Slide 101 text

compondo funções Sunday, October 20, 13

Slide 102

Slide 102 text

compondo funções decomposição de função Sunday, October 20, 13

Slide 103

Slide 103 text

compondo funções higher order functions Sunday, October 20, 13

Slide 104

Slide 104 text

calculando a média móvel Sunday, October 20, 13

Slide 105

Slide 105 text

calculando a média móvel Sunday, October 20, 13

Slide 106

Slide 106 text

calculando a média móvel Sunday, October 20, 13

Slide 107

Slide 107 text

calculando a média móvel Sunday, October 20, 13

Slide 108

Slide 108 text

com diferentes building blocks, é preciso repensar as decisões de design Sunday, October 20, 13

Slide 109

Slide 109 text

OO e FP Juntos? Sunday, October 20, 13

Slide 110

Slide 110 text

Functional in the small, OO in the large. “Tell Above, and Ask Below - Hybridizing OO and Functional design” -Michael Feathers, blog post Sunday, October 20, 13

Slide 111

Slide 111 text

Functional Core, imperative shell. “Destroy all software - episode 72” -Gary Bernhardt, destroy on software screen cast series Sunday, October 20, 13

Slide 112

Slide 112 text

conclusão Sunday, October 20, 13

Slide 113

Slide 113 text

Functional Programming is more a mindset than a particular set of tools or languages. “Functional Thinking” -Neal Ford - IBM Developer Works series Sunday, October 20, 13

Slide 114

Slide 114 text

Obrigado Sunday, October 20, 13

Slide 115

Slide 115 text

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 Sunday, October 20, 13