otimizacao prematura-agile-brazil-12
TRANSCRIPT
![Page 1: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/1.jpg)
Otimização prematura é a raiz de todos os problemas. Código limpo é
otimização?
Lucas Cavalcanti@lucascshttp://lucas.cavalcanti.me
![Page 2: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/2.jpg)
Código Limpo
![Page 3: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/3.jpg)
Nomes bonspublic class BATATINHA { public static double[] To_a_fim_de_ir_na_praia(double mIGuXEixxX, double Bolacha, double LEITE) { if (mIGuXEixxX == 0.0) { throw new putzdeupipocomano("po bixo, isso num pode ser zero naum!!!!"); }
// cara, ela ta moh nervosa hoje! Aquela saia justa com o chefe foi tensa. double hoje_a_martinha_ta_nervosa = Bolacha * Bolacha - 4 * LEITE * mIGuXEixxX;
if (hoje_a_martinha_ta_nervosa < 0.0) { throw new putzdeupipocomano("xiiii a bagaça ta negativa"); }
// ontem fui no cinema ver o filme do batman. Kra, o filme é bom pra kct! double variable114 = (-Bolacha + Math.sqrt(hoje_a_martinha_ta_nervosa)) / (2 * mIGuXEixxX); double variable115 = (-Bolacha - Math.sqrt(hoje_a_martinha_ta_nervosa)) / (2 * mIGuXEixxX); double[] AAAAA = new double[2]; AAAAA[0] = variable114; AAAAA[1] = variable115;
// estou com fome agora, acho que vo pedi uma pizza!!!!! return AAAAA; }}
![Page 4: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/4.jpg)
Orientação a Objetos
![Page 5: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/5.jpg)
Métodos pequenos
![Page 6: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/6.jpg)
Classes pequenas
![Page 7: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/7.jpg)
SOLID
![Page 8: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/8.jpg)
DRY
Produtos produtos = new Produtos(); Produto produto = new Produto(); produto.setNomeProduto("Meu produto"); produto.setPrecoProduto(42); produtos.adicionaProduto(produto);
![Page 9: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/9.jpg)
KISS
![Page 10: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/10.jpg)
“Continuous attention to technical excellence and good design enhances
agility.”
“Atenção contínua à excelência técnica e ao bom design
engrandecem a agilidade”
– Agile Manifesto
![Page 11: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/11.jpg)
Testes automatizados
![Page 12: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/12.jpg)
Testes de Unidade
![Page 13: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/13.jpg)
Testes de integração
![Page 14: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/14.jpg)
Testes End-to-end
![Page 15: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/15.jpg)
TDD
TesteImplemente
Refatore
![Page 16: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/16.jpg)
“Working software is the primary measure of progress.”
“Software funcionando é a principal medida de progresso”
– Agile Manifesto
![Page 17: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/17.jpg)
Integração Contínua
![Page 18: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/18.jpg)
Build pipeline
![Page 19: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/19.jpg)
Entrega contínua
![Page 20: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/20.jpg)
Por que fazemos código limpo?
![Page 21: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/21.jpg)
Por que sim!
![Page 22: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/22.jpg)
Por que é legal!
![Page 23: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/23.jpg)
Por que é uma arte!
![Page 24: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/24.jpg)
Para facilitar a manutenção!!!
![Page 25: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/25.jpg)
Para otimizar a maintainability!
![Page 26: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/26.jpg)
“Our highest priority is to satisfy the customer through early and continuous
delivery of valuable software.”
“Nossa maior prioridade é satisfazer o cliente através de entrega contínua e desde cedo
de software de valor.”
– Agile Manifesto
![Page 27: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/27.jpg)
Early = cedo
![Page 28: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/28.jpg)
“Otimização prematura é a raiz de todos os males”
– Donald E. Knuth
![Page 29: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/29.jpg)
“Programmers waste enormous amounts of time
thinking about, or worrying about, the speed of
noncritical parts of their programs, and these attempts
at efficiency actually have a strong negative impact
when debugging and maintenance are considered. We
should forget about small efficiencies, say about 97%
of the time: premature optimization is the root of all
evil. Yet we should not pass up our opportunities in
that critical 3%.”– Donald E. Knuth
![Page 30: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/30.jpg)
“Programmers waste enormous amounts of time
thinking about, or worrying about, the maintainability
of noncritical parts of their programs, and these
attempts at efficiency actually have a strong negative
impact when debugging and maintenance are
considered. We should forget about small efficiencies,
say about 97% of the time: premature optimization is
the root of all evil. Yet we should not pass up our
opportunities in that critical 3%.”
![Page 31: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/31.jpg)
“Programmers waste enormous amounts of time
thinking about, or worrying about, the maintainability
of noncritical parts of their programs, and these
attempts at efficiency actually have a strong negative
impact when early delivery are considered. We should
forget about small efficiencies, say about 80% of the
time: premature optimization is the root of all evil. Yet
we should not pass up our opportunities in that critical
20%.”– Lucas Cavalcanti
![Page 32: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/32.jpg)
![Page 33: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/33.jpg)
http://martinfowler.com/bliki/DesignStaminaHypothesis.html
![Page 34: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/34.jpg)
![Page 35: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/35.jpg)
Primeiro deploy com valor pro cliente
Segundo deploy com valor pro cliente
Terceiro deploy com valor pro cliente
Quarto deploy com valor pro cliente
![Page 36: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/36.jpg)
![Page 37: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/37.jpg)
Primeiro deploy com valor pro cliente
Segundo deploy com valor pro cliente
Terceiro deploy com valor pro cliente
Quarto deploy com valor pro cliente
Quinto deploy com valor pro cliente
Sexto deploy com valor pro cliente
Sétimo deploy com valor pro cliente
![Page 38: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/38.jpg)
![Page 39: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/39.jpg)
“Simplicity – the art of maximizing the amount of work not done – is essential.”
“Simplicidade – a arte de maximizar a quantidade de trabalho não feito – é essencial”
– Agile Manifesto
![Page 40: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/40.jpg)
“Programmers waste enormous amounts of time
thinking about, or worrying about, the maintainability
of noncritical parts of their programs, and these
attempts at efficiency actually have a strong negative
impact when early delivery are considered. We should
forget about small efficiencies, say about 80% of the
time: premature optimization is the root of all evil. Yet
we should not pass up our opportunities in that critical
20%.”
![Page 41: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/41.jpg)
Conheça as boas práticas!
![Page 42: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/42.jpg)
Mas... não tente atingir a perfeição logo de cara
A não ser que já seja a forma natural ;)
![Page 43: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/43.jpg)
A mudança mais simples primeiro
![Page 44: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/44.jpg)
Melhorias contínuas!
![Page 45: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/45.jpg)
O que muda maistende a ficar melhor
![Page 46: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/46.jpg)
O que muda poucofica com o código menos limpo
![Page 47: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/47.jpg)
Otimize constantemente
Mas não otimize tudo
![Page 48: Otimizacao prematura-agile-brazil-12](https://reader030.vdocuments.com.br/reader030/viewer/2022032616/55a4f07c1a28ab30408b484c/html5/thumbnails/48.jpg)
Obrigado!
Lucas Cavalcanti@lucascshttp://lucas.cavalcanti.me