SlideShare una empresa de Scribd logo
1 de 23
Refactoring
Does your code smell?
 by Martin Tschischauskas
Author
•     http://twitter.com/MartynasC
•     https://www.xing.com/profile/Martin_Ts
      chischauskas




                                                   Martin Tschischauskas
                                                   • Diplom Technische Informatik /
                                                     Computer Engineering
                                                   • Ruby on Rails Developer
                                                   • XING AG
                                                   • Jobs Team



Martin Tschischauskas                     Refactoring – Does your code smell?
Motivation                                             gems


                  Tools                      Conclusion


Martin Tschischauskas     Refactoring – Does your code smell?
Motivation

Does your code smell?




Martin Tschischauskas   Refactoring – Does your code smell?
Motivation

Situation at work




Martin Tschischauskas   Refactoring – Does your code smell?
Motivation

Lots of articles / books




Martin Tschischauskas   Refactoring – Does your code smell?
Motivation

But how to start?




Martin Tschischauskas   Refactoring – Does your code smell?
gems
Code Sadist




Martin Tschischauskas   Refactoring – Does your code smell?
flog

gem install flog

find yourapp -name *.rb | xargs flog




Martin Tschischauskas                   Refactoring – Does your code smell?
flog

• ABC metrics
• computed by counting the number of assignments, branches and conditions
  for a section of code
    • Assignment - an explicit transfer of data into a variable
    • Branch - an explicit forward program branch out of scope - a function
       call, class method call, or new operator
    • Condition - a logical/Boolean test
• |ABC| = sqrt((A*A)+(B*B)+(C*C))

• http://ruby.sadi.st/Flog.html




Martin Tschischauskas             Refactoring – Does your code smell?
flay

gem install flay

find yourapp -name *.rb | xargs flay




Martin Tschischauskas                   Refactoring – Does your code smell?
flay

• DRY – Don’t Repeat yourself
• Analyzes ruby code for structural similarities
   • Differences in literal values,
   • Names,
   • Whitespace,
   • Programming style
   • Are ignored

• http://ruby.sadi.st/Flay.html




Martin Tschischauskas                Refactoring – Does your code smell?
heckle

gem install heckle

heckle Class method –t path_to_your_test –T timeout_in_seconds




Martin Tschischauskas            Refactoring – Does your code smell?
heckle

• Mutation tester
• Changes code and checks if tests fail
• If tests still succeed
     • Code is not covered
     • Or code does nothing

• http://ruby.sadi.st/Heckle.html




Martin Tschischauskas               Refactoring – Does your code smell?
reek

gem install reek

find yourapp -name *.rb | xargs reek




Martin Tschischauskas               Refactoring – Does your code smell?
reek

• Detects code smell
   • Long Method
   • Large Class
   • Feature Envy (using methods of different class excessively)
   • Uncommunicative Name
   • Long Parameter List
   • Nested Iterators
   • https://github.com/troessner/reek/wiki/Code-Smells




Martin Tschischauskas             Refactoring – Does your code smell?
brakeman


gem install brakeman

brakeman yourapp




Martin Tschischauskas   Refactoring – Does your code smell?
brakeman


• Detects possible security issues
• No configuration is needed
• Finds possible
    • XSS
    • SQL Injection
    • …

• http://brakemanscanner.org/




Martin Tschischauskas                Refactoring – Does your code smell?
rails_best_
                                                                          practises



gem install rails_best_practises

rails_best_practices -f html




Martin Tschischauskas              Refactoring – Does your code smell?
rails_best_
                                                                              practises



•    Tries to check code for rails best practises
•    Move code from Controller to Model
•    RESTful Conventions
•    Model
•    Mailer
•    Migration
•    …
•    http://rails-bestpractices.com/




Martin Tschischauskas                  Refactoring – Does your code smell?
Code
                                                               climate
https://codeclimate.com/github/rails/rails




Martin Tschischauskas     Refactoring – Does your code smell
???




Thank
You!
Martin Tschischauskas   Refactoring – Does your code smell?
Credits

                   http://www.flickr.com/photos/dana_moos/5495380861/sizes/o/in/photostream/




                   http://www.flickr.com/photos/digitalsextant/4842845805/sizes/o/in/photostream/




                   http://www.flickr.com/photos/seatbelt67/502255276/sizes/o/in/photostream/




Martin Tschischauskas                          Refactoring – Does your code smell?

Más contenido relacionado

Destacado

Refactoring for design smells
Refactoring for design smellsRefactoring for design smells
Refactoring for design smellsGanesh Samarthyam
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Anshul Vinayak
 
Refaktoryzacja kodu w języku PHP
Refaktoryzacja kodu w języku PHPRefaktoryzacja kodu w języku PHP
Refaktoryzacja kodu w języku PHPDevCastZone
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoringYuriy Gerasimov
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code SmellsMario Sangiorgio
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerIgor Crvenov
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoringkim.mens
 
Code refactoring
Code refactoringCode refactoring
Code refactoringLalit Kale
 
Code Refactoring
Code RefactoringCode Refactoring
Code RefactoringYu-Chih Lin
 
Code Smells and Refactoring
Code Smells and RefactoringCode Smells and Refactoring
Code Smells and RefactoringStanly Lau
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Designguest446c0
 

Destacado (12)

Refactoring for design smells
Refactoring for design smellsRefactoring for design smells
Refactoring for design smells
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
 
Code smells and remedies
Code smells and remediesCode smells and remedies
Code smells and remedies
 
Refaktoryzacja kodu w języku PHP
Refaktoryzacja kodu w języku PHPRefaktoryzacja kodu w języku PHP
Refaktoryzacja kodu w języku PHP
 
Clean code and refactoring
Clean code and refactoringClean code and refactoring
Clean code and refactoring
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Code Smells and Refactoring
Code Smells and RefactoringCode Smells and Refactoring
Code Smells and Refactoring
 
The Smells Of Bad Design
The Smells Of Bad DesignThe Smells Of Bad Design
The Smells Of Bad Design
 

Similar a Refactoring code smell

Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampTheo Jungeblut
 
Badneedles
BadneedlesBadneedles
Badneedlesdimisec
 
Using Tomorrow's CSS Today
Using Tomorrow's CSS TodayUsing Tomorrow's CSS Today
Using Tomorrow's CSS TodayBrian Graves
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)Arnaud Bouchez
 
Code samples that actually compile - Clare Macrae
Code samples that actually compile - Clare MacraeCode samples that actually compile - Clare Macrae
Code samples that actually compile - Clare MacraeClare Macrae
 
First impressions of SparkR: our own machine learning algorithm
First impressions of SparkR: our own machine learning algorithmFirst impressions of SparkR: our own machine learning algorithm
First impressions of SparkR: our own machine learning algorithmInfoFarm
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipTheo Jungeblut
 
Ecmascript - Versão extendida
Ecmascript - Versão extendidaEcmascript - Versão extendida
Ecmascript - Versão extendidaFernanda Bernardo
 
DevOps, CLI, APIs, Oh My! Security Gone Agile
DevOps, CLI, APIs, Oh My!  Security Gone AgileDevOps, CLI, APIs, Oh My!  Security Gone Agile
DevOps, CLI, APIs, Oh My! Security Gone AgileMatt Tesauro
 
Feature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathFeature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathSpark Summit
 
Feature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathFeature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathSpark Summit
 
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...Spark Summit
 
What is quality code? From cruft to craft
What is quality code? From cruft to craftWhat is quality code? From cruft to craft
What is quality code? From cruft to craftNick DeNardis
 

Similar a Refactoring code smell (18)

Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 
Badneedles
BadneedlesBadneedles
Badneedles
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Using Tomorrow's CSS Today
Using Tomorrow's CSS TodayUsing Tomorrow's CSS Today
Using Tomorrow's CSS Today
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)
 
Code samples that actually compile - Clare Macrae
Code samples that actually compile - Clare MacraeCode samples that actually compile - Clare Macrae
Code samples that actually compile - Clare Macrae
 
First impressions of SparkR: our own machine learning algorithm
First impressions of SparkR: our own machine learning algorithmFirst impressions of SparkR: our own machine learning algorithm
First impressions of SparkR: our own machine learning algorithm
 
Clean Code III - Software Craftsmanship
Clean Code III - Software CraftsmanshipClean Code III - Software Craftsmanship
Clean Code III - Software Craftsmanship
 
Ecmascript - Versão extendida
Ecmascript - Versão extendidaEcmascript - Versão extendida
Ecmascript - Versão extendida
 
DevOps, CLI, APIs, Oh My! Security Gone Agile
DevOps, CLI, APIs, Oh My!  Security Gone AgileDevOps, CLI, APIs, Oh My!  Security Gone Agile
DevOps, CLI, APIs, Oh My! Security Gone Agile
 
From legacy to DDD
From legacy to DDDFrom legacy to DDD
From legacy to DDD
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Feature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathFeature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick Pentreath
 
Feature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick PentreathFeature Hashing for Scalable Machine Learning with Nick Pentreath
Feature Hashing for Scalable Machine Learning with Nick Pentreath
 
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...
Feature Hashing for Scalable Machine Learning: Spark Summit East talk by Nick...
 
What is quality code? From cruft to craft
What is quality code? From cruft to craftWhat is quality code? From cruft to craft
What is quality code? From cruft to craft
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Refactoring code smell

  • 1. Refactoring Does your code smell? by Martin Tschischauskas
  • 2. Author • http://twitter.com/MartynasC • https://www.xing.com/profile/Martin_Ts chischauskas Martin Tschischauskas • Diplom Technische Informatik / Computer Engineering • Ruby on Rails Developer • XING AG • Jobs Team Martin Tschischauskas Refactoring – Does your code smell?
  • 3. Motivation gems Tools Conclusion Martin Tschischauskas Refactoring – Does your code smell?
  • 4. Motivation Does your code smell? Martin Tschischauskas Refactoring – Does your code smell?
  • 5. Motivation Situation at work Martin Tschischauskas Refactoring – Does your code smell?
  • 6. Motivation Lots of articles / books Martin Tschischauskas Refactoring – Does your code smell?
  • 7. Motivation But how to start? Martin Tschischauskas Refactoring – Does your code smell?
  • 8. gems Code Sadist Martin Tschischauskas Refactoring – Does your code smell?
  • 9. flog gem install flog find yourapp -name *.rb | xargs flog Martin Tschischauskas Refactoring – Does your code smell?
  • 10. flog • ABC metrics • computed by counting the number of assignments, branches and conditions for a section of code • Assignment - an explicit transfer of data into a variable • Branch - an explicit forward program branch out of scope - a function call, class method call, or new operator • Condition - a logical/Boolean test • |ABC| = sqrt((A*A)+(B*B)+(C*C)) • http://ruby.sadi.st/Flog.html Martin Tschischauskas Refactoring – Does your code smell?
  • 11. flay gem install flay find yourapp -name *.rb | xargs flay Martin Tschischauskas Refactoring – Does your code smell?
  • 12. flay • DRY – Don’t Repeat yourself • Analyzes ruby code for structural similarities • Differences in literal values, • Names, • Whitespace, • Programming style • Are ignored • http://ruby.sadi.st/Flay.html Martin Tschischauskas Refactoring – Does your code smell?
  • 13. heckle gem install heckle heckle Class method –t path_to_your_test –T timeout_in_seconds Martin Tschischauskas Refactoring – Does your code smell?
  • 14. heckle • Mutation tester • Changes code and checks if tests fail • If tests still succeed • Code is not covered • Or code does nothing • http://ruby.sadi.st/Heckle.html Martin Tschischauskas Refactoring – Does your code smell?
  • 15. reek gem install reek find yourapp -name *.rb | xargs reek Martin Tschischauskas Refactoring – Does your code smell?
  • 16. reek • Detects code smell • Long Method • Large Class • Feature Envy (using methods of different class excessively) • Uncommunicative Name • Long Parameter List • Nested Iterators • https://github.com/troessner/reek/wiki/Code-Smells Martin Tschischauskas Refactoring – Does your code smell?
  • 17. brakeman gem install brakeman brakeman yourapp Martin Tschischauskas Refactoring – Does your code smell?
  • 18. brakeman • Detects possible security issues • No configuration is needed • Finds possible • XSS • SQL Injection • … • http://brakemanscanner.org/ Martin Tschischauskas Refactoring – Does your code smell?
  • 19. rails_best_ practises gem install rails_best_practises rails_best_practices -f html Martin Tschischauskas Refactoring – Does your code smell?
  • 20. rails_best_ practises • Tries to check code for rails best practises • Move code from Controller to Model • RESTful Conventions • Model • Mailer • Migration • … • http://rails-bestpractices.com/ Martin Tschischauskas Refactoring – Does your code smell?
  • 21. Code climate https://codeclimate.com/github/rails/rails Martin Tschischauskas Refactoring – Does your code smell
  • 22. ??? Thank You! Martin Tschischauskas Refactoring – Does your code smell?
  • 23. Credits http://www.flickr.com/photos/dana_moos/5495380861/sizes/o/in/photostream/ http://www.flickr.com/photos/digitalsextant/4842845805/sizes/o/in/photostream/ http://www.flickr.com/photos/seatbelt67/502255276/sizes/o/in/photostream/ Martin Tschischauskas Refactoring – Does your code smell?

Notas del editor

  1. "http://www.amazon.de/gp/product/0321604814/ref=as_li_ss_tl?ie=UTF8&camp=1638&creative=19454&creativeASIN=0321604814&linkCode=as2&tag=woweffekt-21"
  2. "http://www.amazon.de/gp/product/0321604814/ref=as_li_ss_tl?ie=UTF8&camp=1638&creative=19454&creativeASIN=0321604814&linkCode=as2&tag=woweffekt-21"