6/4/13
Fighting Code That
Smells
Anna Bulenkova
JetBrains Software Developer
What’s that smell?
WARNING
KEEP CHILDREN AWAY
FROM THIS CONTENT
Why?
Experience
Interruptions
Tiredness
Who cares...
Other Issues
What
happens?
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
• undefined local variable or method `call_me' for
main:Object (NameError)
warning: Object#id will be deprecated; use Obje...
How to fight?
• Learn
• Re-read
• Ask for review
• Pair programming
• Use tools
Code quality tools
•Static
•Runtime
• No code run
• But tool runs
• No side effects
• But no on-the-fly change
Static tools
false positeve
bad alalyzing meta-...
Reek
• Control Couple
• Data Clump
• Feature Envy
• Large Class/Method
• Long Parameters List
• Simulated Polymorphism
Control Couple
Data Clump
Feature Envy
Large Class/Method
One
Third
Long Parameter List
QuickTime™ and a
H.264 decompressor
are needed to see this picture.
Simulated
Polymorphism
• instance_of?
• kind_of?
• is_a?
• ===
• Especially with case
Flog
• ABC Metric
• |ABC| = sqrt((A*A)+(B*B)+(C*C))
ABC Guide Lines0-10 = Awesome
•11-20 = Good enough
•21-40 = Might need refactoring
•41-60 = Possible to justify
•61-100 = ...
ABC = 8.5
Flay
• Duplicates
• Ignores names / literals / values
• Ignores code style
Roodi• Assignment in conditionals
• Case missing else
• Line count
• Names check
• Cyclomatic omplexityс
• Empty rescue bo...
metrics_fu/metrical
• Flay
• Flog
• Rails Best Practices
• Reek
• Roodi
• Dynamic tools
• Fancy HTML report
Where to get?
Who’s gonna clean
everything for me?
RubyMine
• Inspections
• Duplicates
RubyMine Inspections
• Static
• On-the-fly analysis
Static analysis
QuickTime™ and a
H.264 decompressor
are needed to see this picture.
QuickTime™ and a
H.264 decompressor
are needed to see this picture.
On-The-Fly Analysis
Duplicates
There’s no cure-all
6/4/13
Thanks for
watching!
Smells @muc_rubyshift 06/2013
Smells @muc_rubyshift 06/2013
Smells @muc_rubyshift 06/2013
Smells @muc_rubyshift 06/2013
Smells @muc_rubyshift 06/2013
Upcoming SlideShare
Loading in...5
×

Smells @muc_rubyshift 06/2013

93

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
93
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Smells @muc_rubyshift 06/2013

  1. 1. 6/4/13 Fighting Code That Smells Anna Bulenkova JetBrains Software Developer
  2. 2. What’s that smell?
  3. 3. WARNING KEEP CHILDREN AWAY FROM THIS CONTENT
  4. 4. Why?
  5. 5. Experience
  6. 6. Interruptions
  7. 7. Tiredness
  8. 8. Who cares...
  9. 9. Other Issues
  10. 10. What happens?
  11. 11. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  12. 12. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  13. 13. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  14. 14. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  15. 15. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  16. 16. • undefined local variable or method `call_me' for main:Object (NameError) warning: Object#id will be deprecated; use Object#object_id • warning: Object#id will be deprecated; use Object#object_id • Dead code • Copy/Paste • Complexity • code_styleAnd_FWpatternViolations
  17. 17. How to fight?
  18. 18. • Learn • Re-read • Ask for review • Pair programming • Use tools
  19. 19. Code quality tools •Static •Runtime
  20. 20. • No code run • But tool runs • No side effects • But no on-the-fly change Static tools false positeve bad alalyzing meta-programming false positeve bad alalyzing meta-programming
  21. 21. Reek • Control Couple • Data Clump • Feature Envy • Large Class/Method • Long Parameters List • Simulated Polymorphism
  22. 22. Control Couple
  23. 23. Data Clump
  24. 24. Feature Envy
  25. 25. Large Class/Method One Third
  26. 26. Long Parameter List QuickTime™ and a H.264 decompressor are needed to see this picture.
  27. 27. Simulated Polymorphism • instance_of? • kind_of? • is_a? • === • Especially with case
  28. 28. Flog • ABC Metric • |ABC| = sqrt((A*A)+(B*B)+(C*C))
  29. 29. ABC Guide Lines0-10 = Awesome •11-20 = Good enough •21-40 = Might need refactoring •41-60 = Possible to justify •61-100 = Danger •100-200 = Whoop, whoop, whoop •200 + = Someone please think of the children
  30. 30. ABC = 8.5
  31. 31. Flay • Duplicates • Ignores names / literals / values • Ignores code style
  32. 32. Roodi• Assignment in conditionals • Case missing else • Line count • Names check • Cyclomatic omplexityс • Empty rescue body • For to foreach • Parameters number подровнятьподровнять
  33. 33. metrics_fu/metrical • Flay • Flog • Rails Best Practices • Reek • Roodi • Dynamic tools • Fancy HTML report
  34. 34. Where to get?
  35. 35. Who’s gonna clean everything for me?
  36. 36. RubyMine • Inspections • Duplicates
  37. 37. RubyMine Inspections • Static • On-the-fly analysis
  38. 38. Static analysis QuickTime™ and a H.264 decompressor are needed to see this picture.
  39. 39. QuickTime™ and a H.264 decompressor are needed to see this picture. On-The-Fly Analysis
  40. 40. Duplicates
  41. 41. There’s no cure-all
  42. 42. 6/4/13 Thanks for watching!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×