SlideShare ist ein Scribd-Unternehmen logo
1 von 68
Downloaden Sie, um offline zu lesen
Fazendo as pazes com

                                    CÓDIGO
                                      LEGADO

quinta-feira, 30 de junho de 2011
~ 12 anos de estrada
                                    ~ Desenvolvedor Senior da Globo.com
                                    ~ Apaixonado pelo que faço ...




quinta-feira, 30 de junho de 2011
Guilherme Souza (não pode vir)

                                    ~ 4 anos de estrada
                                    ~ Desenvolvedor da Globo.com
                                    ~ Hacker por definição e apaixonado por tecnologia




quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
NOT



quinta-feira, 30 de junho de 2011
Made by
                                       Other


quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Cuidado
                         você pode estar
                        escrevendo código
                         legado agora ...
quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
TESTE

quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Clean Code
                               is not ENOUGH


quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Era uma vez ...


quinta-feira, 30 de junho de 2011
E daí ?


quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Era uma vez ...


quinta-feira, 30 de junho de 2011
Refazer é caro




quinta-feira, 30 de junho de 2011
Missão
                               Ensinar técnicas e formas de pensar que
                               facilitem e deixem a todos confiantes para
                               mexer em qualquer base de código




quinta-feira, 30 de junho de 2011
Era uma vez ...


quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Caminho é longo ...




quinta-feira, 30 de junho de 2011
Complexidade é alta ...




quinta-feira, 30 de junho de 2011
Mas o prazo é o
               MESMO
quinta-feira, 30 de junho de 2011
Por onde começar?


quinta-feira, 30 de junho de 2011
Escolha suas batalhas e




                                    .. vença uma por vez ...



quinta-feira, 30 de junho de 2011
Dependencia




                    Aumentar                       Efeito
                 cobertura de teste               Colateral


quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Identify Change Points




quinta-feira, 30 de junho de 2011
Find Test Points




quinta-feira, 30 de junho de 2011
Break Dependencies




quinta-feira, 30 de junho de 2011
Cover with tests




quinta-feira, 30 de junho de 2011
Change



quinta-feira, 30 de junho de 2011
Como eu faço isso ?
quinta-feira, 30 de junho de 2011
example.rb                                                                Page 1
 class Example
   def send_welcome_msg
     clients = Client.get_all
     clients.each do |client|
       addresses = client.get_all_users
       body = << EOF
         Welcome to our system. We're very happy for your presence here.
       EOF
       addresses.each do |user|
         sender = MailSender.new
         sender.from= "aoqfonseca@gmail.com"
         sender.to= user.mail
         sender.body=body
         sender.send
       end
       client.billing << Charging.new(200)
       account = client.bank_account
       account.charge
     end
   end
 end




quinta-feira, 30 de junho de 2011
example.rb                                                                Page 1
 class Example
   def send_welcome_msg
     clients = Client.get_all
                                                               Quero colocar
     clients.each do |client|
       addresses = client.get_all_users
                                                               aqui um audit
       body = << EOF
         Welcome to our system. We're very happy for your presence here.
       EOF
       addresses.each do |user|
         sender = MailSender.new
         sender.from= "aoqfonseca@gmail.com"
         sender.to= user.mail
         sender.body=body
         sender.send
       end
       client.billing << Charging.new(200)
       account = client.bank_account
       account.charge
     end
   end
 end




quinta-feira, 30 de junho de 2011
Sprout

                                    Methods




quinta-feira, 30 de junho de 2011
Change Point




quinta-feira, 30 de junho de 2011
New Tested
                                            Method




                            Change Point




quinta-feira, 30 de junho de 2011
example.rb                                                                   Page 1

          class Example
            def send_welcome_msg
              clients = Client.get_all
              clients.each do |client|
                addresses = client.get_all_users
                body = << EOF
                  Welcome to our system. We're very happy for your presence here.
                EOF

                  addresses.each do |user|
                    sender = MailSender.new
                    sender.from= "aoqfonseca@gmail.com"
                    sender.to= user.mail
                    sender.body=body
                    sender.send
                    audit_send(user.mail, body)
                  end
                  client.billing << Charging.new(200)
                  account = client.bank_account
                  account.charge
                end
              end

            def audit_send(mail, body)
              audit = Audit.new
              audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
          > Date.now)
              audit.save
            end
          end




quinta-feira, 30 de junho de 2011
example.rb                                                                   Page 1

          class Example
            def send_welcome_msg
              clients = Client.get_all
              clients.each do |client|
                addresses = client.get_all_users
                body = << EOF
                  Welcome to our system. We're very happy for your presence here.
                EOF

                  addresses.each do |user|
                    sender = MailSender.new
                    sender.from= "aoqfonseca@gmail.com"
                    sender.to= user.mail
                    sender.body=body
                    sender.send
                    audit_send(user.mail, body)
                  end
                  client.billing << Charging.new(200)
                  account = client.bank_account
                  account.charge
                end
              end

            def audit_send(mail, body)
              audit = Audit.new
              audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
          > Date.now)
              audit.save
            end
          end




quinta-feira, 30 de junho de 2011
example.rb                                                                   Page 1

          class Example
            def send_welcome_msg
              clients = Client.get_all
              clients.each do |client|
                addresses = client.get_all_users
                body = << EOF
                  Welcome to our system. We're very happy for your presence here.
                EOF

                  addresses.each do |user|
                    sender = MailSender.new
                    sender.from= "aoqfonseca@gmail.com"
                    sender.to= user.mail
                    sender.body=body
                    sender.send
                    audit_send(user.mail, body)
                  end
                  client.billing << Charging.new(200)
                  account = client.bank_account
                  account.charge
                end
              end

            def audit_send(mail, body)
              audit = Audit.new
              audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
          > Date.now)
              audit.save
            end
          end




quinta-feira, 30 de junho de 2011
example.rb                                                                   Page 1

          class Example
            def send_welcome_msg
              clients = Client.get_all
              clients.each do |client|
                addresses = client.get_all_users
                body = << EOF
                  Welcome to our system. We're very happy for your presence here.
                EOF

                  addresses.each do |user|
                    sender = MailSender.new
                                                  DO
                                                A
                    sender.from= "aoqfonseca@gmail.com"

                                              ST
                    sender.to= user.mail


                                            TE
                    sender.body=body
                    sender.send
                    audit_send(user.mail, body)
                  end
                  client.billing << Charging.new(200)
                  account = client.bank_account
                  account.charge
                end
              end

            def audit_send(mail, body)
              audit = Audit.new
              audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
          > Date.now)
              audit.save
            end
          end




quinta-feira, 30 de junho de 2011
Sprout

                                    Classes




quinta-feira, 30 de junho de 2011
Change Point




quinta-feira, 30 de junho de 2011
New Tested
                                             Class




                            Change Point




quinta-feira, 30 de junho de 2011
example.rb[+]                                                                Page 1

 class Example
   def welcome
     clients = Client.get_all
     clients.each do |client|
       addresses = client.get_all_users
       body = << EOF
         Welcome to our system. We're very happy for your presence here.
       EOF
          addresses.each do |user|
            sender = MailSender.new
            sender.from= "aoqfonseca@gmail.com"
            sender.to= user.mail
            sender.body=body
            sender.send
            audit_send(user.mail, body)
          end
        end
      end
   def audit_send(mail, body)
     audit = Audit.new
     audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
 > Date.now)
     audit.save
   end
 end




quinta-feira, 30 de junho de 2011
Wrap

                                    Methods




quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Change Point




quinta-feira, 30 de junho de 2011
Wrap Tested Method




                                       Change Point




quinta-feira, 30 de junho de 2011
example.rb[+]                                                                Page 1
  class Example
    def old_welcome(clients)
      clients.each do |client|
        addresses = client.get_all_users
        body = << EOF
          Welcome to our system. We're very happy for your presence here.
        EOF
          addresses.each do |user|
            sender = MailSender.new
            sender.from= "aoqfonseca@gmail.com"
            sender.to= user.mail
            sender.body=body
            sender.send
            audit_send(user.mail, body)
          end
        end
      end

      def welcome
        clients= Client.get_all
        old_welcome clients
        Billing.charge(clients)
      end


    def audit_send(mail, body)
      audit = Audit.new
      audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
  > Date.now)
      audit.save
    end
  end

quinta-feira, 30 de junho de 2011
example.rb[+]                                                                Page 1
  class Example
    def old_welcome(clients)
      clients.each do |client|
        addresses = client.get_all_users
        body = << EOF
          Welcome to our system. We're very happy for your presence here.
        EOF
          addresses.each do |user|
            sender = MailSender.new
            sender.from= "aoqfonseca@gmail.com"
            sender.to= user.mail
            sender.body=body
            sender.send
            audit_send(user.mail, body)
          end
        end
      end

      def welcome
        clients= Client.get_all
        old_welcome clients
        Billing.charge(clients)
      end


    def audit_send(mail, body)
      audit = Audit.new
      audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
  > Date.now)
      audit.save
    end
  end

quinta-feira, 30 de junho de 2011
example.rb[+]                                                                Page 1
  class Example
    def old_welcome(clients)
      clients.each do |client|
        addresses = client.get_all_users
        body = << EOF
          Welcome to our system. We're very happy for your presence here.
        EOF
          addresses.each do |user|
            sender = MailSender.new
            sender.from= "aoqfonseca@gmail.com"
            sender.to= user.mail
            sender.body=body
            sender.send
            audit_send(user.mail, body)
          end
        end
      end

      def welcome
        clients= Client.get_all
        old_welcome clients
        Billing.charge(clients)
      end


    def audit_send(mail, body)
      audit = Audit.new
      audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at =
  > Date.now)
      audit.save
    end
  end

quinta-feira, 30 de junho de 2011
Wrap

                                    Classes




quinta-feira, 30 de junho de 2011
quinta-feira, 30 de junho de 2011
Change Point




quinta-feira, 30 de junho de 2011
Wrap Tested Class




                                      Change Point




quinta-feira, 30 de junho de 2011
Acabou ?

                                    Era só isso?



quinta-feira, 30 de junho de 2011
NEGATIVO
quinta-feira, 30 de junho de 2011
Vamos ao refactoring ...



quinta-feira, 30 de junho de 2011
ATENÇÃO

                     Não vamos reinventar
                           nada !

quinta-feira, 30 de junho de 2011
SOLID
              SMELLS (Fowler)
              Patterns
              Refactoring Patterns

quinta-feira, 30 de junho de 2011
Foco



quinta-feira, 30 de junho de 2011
Bora codar um pouco ...




quinta-feira, 30 de junho de 2011
Obrigado !!!
                                    @aoqfonseca


                                    aoqfonseca@gmail.com


                                    www.andrefonseca.net




quinta-feira, 30 de junho de 2011

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Codigo legado fisl

  • 1. Fazendo as pazes com CÓDIGO LEGADO quinta-feira, 30 de junho de 2011
  • 2. ~ 12 anos de estrada ~ Desenvolvedor Senior da Globo.com ~ Apaixonado pelo que faço ... quinta-feira, 30 de junho de 2011
  • 3. Guilherme Souza (não pode vir) ~ 4 anos de estrada ~ Desenvolvedor da Globo.com ~ Hacker por definição e apaixonado por tecnologia quinta-feira, 30 de junho de 2011
  • 4. quinta-feira, 30 de junho de 2011
  • 5. quinta-feira, 30 de junho de 2011
  • 6. NOT quinta-feira, 30 de junho de 2011
  • 7. Made by Other quinta-feira, 30 de junho de 2011
  • 8. quinta-feira, 30 de junho de 2011
  • 9. Cuidado você pode estar escrevendo código legado agora ... quinta-feira, 30 de junho de 2011
  • 10. quinta-feira, 30 de junho de 2011
  • 11. TESTE quinta-feira, 30 de junho de 2011
  • 12. quinta-feira, 30 de junho de 2011
  • 13. Clean Code is not ENOUGH quinta-feira, 30 de junho de 2011
  • 14. quinta-feira, 30 de junho de 2011
  • 15. Era uma vez ... quinta-feira, 30 de junho de 2011
  • 16. E daí ? quinta-feira, 30 de junho de 2011
  • 17. quinta-feira, 30 de junho de 2011
  • 18. quinta-feira, 30 de junho de 2011
  • 19. Era uma vez ... quinta-feira, 30 de junho de 2011
  • 20. Refazer é caro quinta-feira, 30 de junho de 2011
  • 21. Missão Ensinar técnicas e formas de pensar que facilitem e deixem a todos confiantes para mexer em qualquer base de código quinta-feira, 30 de junho de 2011
  • 22. Era uma vez ... quinta-feira, 30 de junho de 2011
  • 23. quinta-feira, 30 de junho de 2011
  • 24. Caminho é longo ... quinta-feira, 30 de junho de 2011
  • 25. Complexidade é alta ... quinta-feira, 30 de junho de 2011
  • 26. Mas o prazo é o MESMO quinta-feira, 30 de junho de 2011
  • 27. Por onde começar? quinta-feira, 30 de junho de 2011
  • 28. Escolha suas batalhas e .. vença uma por vez ... quinta-feira, 30 de junho de 2011
  • 29. Dependencia Aumentar Efeito cobertura de teste Colateral quinta-feira, 30 de junho de 2011
  • 30. quinta-feira, 30 de junho de 2011
  • 32. Find Test Points quinta-feira, 30 de junho de 2011
  • 34. Cover with tests quinta-feira, 30 de junho de 2011
  • 35. Change quinta-feira, 30 de junho de 2011
  • 36. Como eu faço isso ? quinta-feira, 30 de junho de 2011
  • 37. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send end client.billing << Charging.new(200) account = client.bank_account account.charge end end end quinta-feira, 30 de junho de 2011
  • 38. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all Quero colocar clients.each do |client| addresses = client.get_all_users aqui um audit body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send end client.billing << Charging.new(200) account = client.bank_account account.charge end end end quinta-feira, 30 de junho de 2011
  • 39. Sprout Methods quinta-feira, 30 de junho de 2011
  • 40. Change Point quinta-feira, 30 de junho de 2011
  • 41. New Tested Method Change Point quinta-feira, 30 de junho de 2011
  • 42. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end client.billing << Charging.new(200) account = client.bank_account account.charge end end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 43. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end client.billing << Charging.new(200) account = client.bank_account account.charge end end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 44. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end client.billing << Charging.new(200) account = client.bank_account account.charge end end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 45. example.rb Page 1 class Example def send_welcome_msg clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new DO A sender.from= "aoqfonseca@gmail.com" ST sender.to= user.mail TE sender.body=body sender.send audit_send(user.mail, body) end client.billing << Charging.new(200) account = client.bank_account account.charge end end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 46. Sprout Classes quinta-feira, 30 de junho de 2011
  • 47. Change Point quinta-feira, 30 de junho de 2011
  • 48. New Tested Class Change Point quinta-feira, 30 de junho de 2011
  • 49. example.rb[+] Page 1 class Example def welcome clients = Client.get_all clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end end end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 50. Wrap Methods quinta-feira, 30 de junho de 2011
  • 51. quinta-feira, 30 de junho de 2011
  • 52. Change Point quinta-feira, 30 de junho de 2011
  • 53. Wrap Tested Method Change Point quinta-feira, 30 de junho de 2011
  • 54. example.rb[+] Page 1 class Example def old_welcome(clients) clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end end end def welcome clients= Client.get_all old_welcome clients Billing.charge(clients) end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 55. example.rb[+] Page 1 class Example def old_welcome(clients) clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end end end def welcome clients= Client.get_all old_welcome clients Billing.charge(clients) end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 56. example.rb[+] Page 1 class Example def old_welcome(clients) clients.each do |client| addresses = client.get_all_users body = << EOF Welcome to our system. We're very happy for your presence here. EOF addresses.each do |user| sender = MailSender.new sender.from= "aoqfonseca@gmail.com" sender.to= user.mail sender.body=body sender.send audit_send(user.mail, body) end end end def welcome clients= Client.get_all old_welcome clients Billing.charge(clients) end def audit_send(mail, body) audit = Audit.new audit.operations << SendMailOperatio.new(:to=> mail, :body => body, created_at = > Date.now) audit.save end end quinta-feira, 30 de junho de 2011
  • 57. Wrap Classes quinta-feira, 30 de junho de 2011
  • 58. quinta-feira, 30 de junho de 2011
  • 59. Change Point quinta-feira, 30 de junho de 2011
  • 60. Wrap Tested Class Change Point quinta-feira, 30 de junho de 2011
  • 61. Acabou ? Era só isso? quinta-feira, 30 de junho de 2011
  • 63. Vamos ao refactoring ... quinta-feira, 30 de junho de 2011
  • 64. ATENÇÃO Não vamos reinventar nada ! quinta-feira, 30 de junho de 2011
  • 65. SOLID SMELLS (Fowler) Patterns Refactoring Patterns quinta-feira, 30 de junho de 2011
  • 66. Foco quinta-feira, 30 de junho de 2011
  • 67. Bora codar um pouco ... quinta-feira, 30 de junho de 2011
  • 68. Obrigado !!! @aoqfonseca aoqfonseca@gmail.com www.andrefonseca.net quinta-feira, 30 de junho de 2011