Broken windows de práticas ágeis

530 views

Published on

Presented at Agile In Rio, October 2013.

This presentation discusses the risks of leaving small broken windows behind when dealing with a software project and it focuses on easy ways of keeping the code maintainable through time.

Slides are (almost) in English. Codes are in Portuguese, though. I might translate them, eventually.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
530
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Broken windows de práticas ágeis

  1. 1. Pra começar...
  2. 2. 1969
  3. 3. 1969 Hmm... I have this idea
  4. 4. 1969 Hmm... I have this idea
  5. 5. 10 minutes
  6. 6. 1 week
  7. 7. wait!
  8. 8. what if...
  9. 9. what if...
  10. 10. Just like the Bronx!
  11. 11. No one cares
  12. 12. No one cares Why should I?
  13. 13. Broken windows de práticas Ceci Fernandes @cecifernandes
  14. 14. Which practices?
  15. 15. Which practices? Diz aí!
  16. 16. practices process
  17. 17. pair programming
  18. 18. daily meeting
  19. 19. definition of done
  20. 20. continuous delivery or continuous deployment
  21. 21. practices process many other
  22. 22. practices process code
  23. 23. Code conventions make you feel too conventional?
  24. 24. Code conventions make you feel too conventional? Let's make it better!
  25. 25. Much better now...
  26. 26. Not for long.
  27. 27. Code conventions
  28. 28. public class Taxi { public double cobra(double km, int minutos) { if (horarioPadrao()) { return precoBase(km, minutos); } else return precoBase(km, minutos) * extra; } }
  29. 29. public class Taxi { public double cobra(double km, int minutos) { if (horarioPadrao()) return precoBase(km, minutos); else return precoBase(km, minutos) * extra; } }
  30. 30. public class Taxi { public double cobra(double Km, int minutos) { if (horario_padrao()) return precoBase(Km, minutos); else return precoBase(Km, minutos) * EXTRA; } }
  31. 31. public class Taxi { public double cobra(double km, int t) { double valor = calcula(km, t); if (maisCaro()) { return valor * extra; } return valor; } }
  32. 32. public class Taxi { public double cobra(double km,int minutos) { if (horarioPadrao()) return precoBase(km,minutos); else return precoBase(km,minutos)*extra; } }
  33. 33. ?
  34. 34. Your turn! What can you do?
  35. 35. Não é pela posição das chaves
  36. 36. What conventions then?
  37. 37. public void atualiza(final List<Parcela> parcelasAAtualizar, final Usuario usuario, List<Feriado> feriados) { for (Parcela p : parcelasAAtualizar) { if (old.isInicial() || auxiliar || financeiro) { if (old.getConta() != null) { // } if (p.getConta() != null) { // } } if (!old.isFinal()) { if (auxiliar || financeiro) { // if(old.getPodeUsarNovosCamposDeImposto()) { // } else { // } } // goes on a long way...
  38. 38. public void atualiza(final List<Parcela> parcelasAAtualizar, final Usuario usuario, List<Feriado> feriados) { for (Parcela p : parcelasAAtualizar) { if (old.isInicial() || auxiliar || financeiro) { if (old.getConta() != null) { // } if (p.getConta() != null) { // } } if (!old.isFinal()) { if (auxiliar || financeiro) { // if(old.getPodeUsarNovosCamposDeImposto()) { // } else { // } } // goes on a long way... Cyclomatic complexity
  39. 39. public TurmaController(HorarioDao horarioDao, TurmaDao turmaDao, SalaDao salaDao, CursoDao cursoDao, Info info, HttpServletResponse response, Result result, EnhancedValidator enhancedValidator, UsuarioDao usuarioDao, InstrutorEmAulaDao instrutorEmAulaDao) { this._________ = _________; }
  40. 40. public TurmaController(HorarioDao horarioDao, TurmaDao turmaDao, SalaDao salaDao, CursoDao cursoDao, Info info, HttpServletResponse response, Result result, EnhancedValidator enhancedValidator, UsuarioDao usuarioDao, InstrutorEmAulaDao instrutorEmAulaDao) { this._________ = _________; } [AE]fferent coupling
  41. 41. public void generateRequestToken(CustomOAuthAccessor accessor) { // generate oauth_token and oauth_secret String consumer_key = accessor.getAccessor().consumer.getProperty("name"); // generate token and secret based on consumer_key // for now use md5 of name + current time as token String token_data = consumer_key + System.currentTimeMillis(); String token = scramble(token_data); // creates secret accordingly String secret_data = consumer_key + System.currentTimeMillis() + token; String secret = scramble(secret_data); accessor.setRequestToken(token); accessor.setSecret(secret); accessor.setAccessToken(null); // add to the local cache customAccessors.add(accessor); }
  42. 42. public void generateRequestToken(CustomOAuthAccessor accessor) { // generate oauth_token and oauth_secret String consumer_key = accessor.getAccessor().consumer.getProperty("name"); // generate token and secret based on consumer_key // for now use md5 of name + current time as token String token_data = consumer_key + System.currentTimeMillis(); String token = scramble(token_data); // creates secret accordingly String secret_data = consumer_key + System.currentTimeMillis() + token; String secret = scramble(secret_data); accessor.setRequestToken(token); accessor.setSecret(secret); accessor.setAccessToken(null); // add to the local cache customAccessors.add(accessor); } Do not comment
  43. 43. public void generateRequestToken(CustomOAuthAccessor accessor) { // generate oauth_token and oauth_secret String consumer_key = accessor.getAccessor().consumer.getProperty("name"); // generate token and secret based on consumer_key // for now use md5 of name + current time as token String token_data = consumer_key + System.currentTimeMillis(); String token = scramble(token_data); // creates secret accordingly String secret_data = consumer_key + System.currentTimeMillis() + token; String secret = scramble(secret_data); accessor.setRequestToken(token); accessor.setSecret(secret); accessor.setAccessToken(null); // add to the local cache customAccessors.add(accessor); } Do not comment
  44. 44. ?
  45. 45. How about...
  46. 46. Why is ugly a problem?
  47. 47. public class Pagamento { public void paga (Funcionario f) { int horasTrabalhadas = f.getHorasTrabalhadas(); if (f.getCargo() == Cargo.INSTRUTOR) { horasTrabalhadas += f.getHorasAulaDadas(); } double salario = f.getValorHora() * horasTrabalhadas; imprimeRecibo(salario); } //... }
  48. 48. public class Pagamento { public void paga (Funcionario f) { int horasTrabalhadas = f.getHorasTrabalhadas(); if (f.getCargo() == Cargo.INSTRUTOR) { horasTrabalhadas += f.getHorasAulaDadas(); } double salario = f.getValorHora() * horasTrabalhadas; imprimeRecibo(salario); } //... }
  49. 49. public class Pagamento { public void paga (Funcionario f) { int horasTrabalhadas = f.getHorasTrabalhadas(); if (f.getCargo() == Cargo.INSTRUTOR) { horasTrabalhadas += f.getHorasAulaDadas(); } double salario = f.getValorPorHora() * horasTrabalhadas; if (f.getCargo() == Cargo.COMERCIAL) { salario += f.getCursosVendidos() * f.valorComissao(); } imprimeRecibo(salario); } }
  50. 50. Should have fixed me earlier
  51. 51. Back to the start...
  52. 52. What are the broken windows in your team?
  53. 53. What are the broken windows in your team? Are yours the same as the person next to you?
  54. 54. What are the broken windows in your team? How will you fix them?
  55. 55. Broken windows de práticas Ceci Fernandes @cecifernandes

×