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.

Code Smells

7,099 views

Published on

Published in: Technology
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD TH1S BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK Here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB EBOOK Here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK Here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB EBOOK Here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc EBOOK Here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Code Smells

  1. 1. Rodrigo Branas – @rodrigobranas - http://www.agilecode.com.br Code Smells
  2. 2. http://www.slideshare.net/rodrigobranas
  3. 3. @rodrigobranas rodrigo.branas@gmail.com http://www.agilecode.com.brFormação AcadêmicaCiências da Computação – UFSCGerenciamento de Projetos - FGVCertificaçõesSCJA, SCJP, SCJD, SCWCD, SCBCD, PMP, MCP e CSM
  4. 4. Rodrigo Branas – rodrigo.branas@gmail.com10 anos de experiência na plataforma Java1000 horas em sala de aulaMais de 50 palestras em eventosLíder da área de desenvolvimento na GenneraAutor da revista Java MagazinePalestranteInstrutor da Academia Java e Agile da GlobalcodeCriador dos treinamentos de Clean Code, Selenium eMaven da Agile CodeTrabalhou com as empresas: EDS, HP, GM, Citibank,OnCast, Globalcode, V.Office, Dígitro, Softplan, Unimed,Suntech, Vale do Rio Doce, Senai, NET.
  5. 5. Um smell é um sintoma queocorre dentro do código fonte e que pode ser um indicador de problemas.
  6. 6. Qual é a relação entre code smells e defeitos?
  7. 7. Aerodinâmica ou distância da margem
  8. 8. Técnicas de refactoring aplicáveis: Todas relacionadas asimplificação de condicionais Extrair Método
  9. 9. Comentários no código
  10. 10. Autor do código acaba inserindo comentários para tentar compensar a complexidade ou nebulosidade do código
  11. 11. Técnicas de refactoring aplicáveis: Extrair Método
  12. 12. Se os comentários forem desnecessários:Simplesmente apague-os.
  13. 13. 1. ...2. public void transmitirMensagem(String mensagem) {3. // Criando um envelope para enviar a mensagem4. Envelope envelope = new Envelope();5. // Definindo a mensagem no envelope6. envelope.setMensagem(mensagem);7. // Enviando o envelope8. this.sendEnvelope(envelope);9. }10. ...
  14. 14. 1. ...2. public void transmitirMensagem(String mensagem) {3.4. Envelope envelope = new Envelope();5.6. envelope.setMensagem(mensagem);7.8. this.sendEnvelope(envelope);9. }10. ...
  15. 15. 1. ...2. public void transmitirMensagem(String mensagem) {3. Envelope envelope = new Envelope();4. envelope.setMensagem(mensagem);5. this.sendEnvelope(envelope);6. }7. ...
  16. 16. Método longo
  17. 17. Qual é o tamanho ideal?
  18. 18. Sempre deve ser o menor possível
  19. 19. Técnicas de refactoring aplicáveis: Extrair Método
  20. 20. Classes grandes
  21. 21. Por que as classes crescem tanto?
  22. 22. Coesão baixa
  23. 23. Se a sua classe possui muitos métodos longos, resolva um problema de cada vez.
  24. 24. Classes Utilitárias
  25. 25. Técnicas de refactoring aplicáveis: Extrair Classe Extrair Subclasse Mover Método
  26. 26. Longa lista de parâmetros
  27. 27. Qual é o número ideal deparâmetros de um método?
  28. 28. Técnicas de refactoring aplicáveis:Substituir Parâmetro por Método Preservar Objeto Inteiro Introduzir Objeto Parâmetro
  29. 29. Código Duplicado
  30. 30. Técnicas de refactoring aplicáveis: Extrair Método Extrair ClasseSubir Método na HierarquiaIntroduzir Template Method
  31. 31. Grupos de Dados
  32. 32. Existem alguns dados que andam sempre juntos, agrupados.É comum observar esses dados andando juntos na forma de parâmetros.
  33. 33. 1. ...2. public Extrato emitirExtrato(Date inicio, Date fim);3. public double calcularJurosPeriodo(Date inicio, Date fim);4. public boolean verificarCredito(Date inicio, Date fim);5. ...
  34. 34. Técnicas de refactoring aplicáveis: Extrair ClasseIntroduzir Objeto Parâmetro Preservar o Objeto Inteiro
  35. 35. Comandos Switch
  36. 36. Comandos switch tendem a serprocedurais e a se repetirem em diversas partes do software. Ao se deparar com um comando switch você deve considerar aintrodução de um comportamento mais polimórfico.
  37. 37. Técnicas de refactoring aplicáveis: Substituir Enumeração pelo Padrão State ou StrategySubstituir Comando Condicional por Polimorfismo
  38. 38. Generalidade Especulativa
  39. 39. “Eu acho que vamos precisar disso algum dia!”
  40. 40. Excesso de complexidade para tratar casos que ainda não existem.
  41. 41. Técnicas de refactoring aplicáveis:Condensar Hierarquia Internalizar Classe Remover Parâmetro Renomear Método
  42. 42. Cadeias de Mensagens
  43. 43. Um cliente pede algo a umobjeto, que pede a outro objeto,que pede a outro objeto e assim por diante.
  44. 44. 1. ...2. if (cliente.getCarteira().getCartao().verificarValidade()) {3. cliente.getCarteira().getCartao().comprar(valor);4. }5. ...
  45. 45. Lei de Demeter
  46. 46. Não fale com estranhos
  47. 47. Técnicas de refactoring aplicáveis: Ocultar Delegação

×