Ola.	  
You’re	  making	  me	  	   refactor.	  You	  won’t	   like	  me	    when	  I	   refactor	  
Refactoring?	  
a	  change	  made	  to	  the	  internal	                     structure	  of	  so=ware	  to	  make	  it	                   ...
 Dont	  touch	  anything	  that	  doesnt	                  have	  coverage.	  Otherwise,	  youre	  not	  refactoring;	    ...
a	  change	  made	  to	  the	  internal	                     structure	  of	  so=ware	  to	  make	  it	                   ...
SomeHmes	  it	  just	  feels	  right.	  
Step	  1:	  Measure	  the	   toxicity.	  
Smells	  in	  the	  code	  
CyclomaHc	  Complexity	  5	  to	  7	  is	  decent	  for	  most	  ruby	  code	  
Saikuro	  
Assignments,	  Branches,	  Calls	  	             with	  Flog	  Watch	  for	  scores	  greater	  than	  40	  
Flog	  
DuplicaHon	  with	  Flay	  Watch	  for	  scores	  greater	  than	  30	  
Control	  Couples	  and	  more	  	                     with	  Reek	  Simulated	  Polymorphism	  Feature	  Envy	  UHlity	  ...
LinHng	  with	  Dust/Nitpick	  JSLint	  for	  Ruby	  
Common	  smells	  	     in	  Ruby	  	  
PrimiHve	  Obsession	  
Feature	  Envy	  
Meta-­‐programming	   Keep	  it	  simple.	  	   Keep	  it	  declaraHve	  
Toxicity	  is	  more	  than	  code	  smells	  
“The	  real	  problem	  I	  have	  with	  the	  CK	  suite	  and	  similar	  metrics	  is	  that	  they	  only	  measure	 ...
DEPENDENCY	  
Tangles	  
Step	  2:	  Make	  it	  visible	  
Treemaps	  (Max	  CC)	  hbp://mbostock.github.com/protovis/	  
Treemaps	  
Dependency	  matrix	  
Step	  3:	  Agree	  on	  the	  fix	  
Step	  4:	  	  	  Go	  fix	  it	  
Obrigado	  
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Thoughtworks Brazil, Code Quality
Upcoming SlideShare
Loading in …5
×

Thoughtworks Brazil, Code Quality

832 views

Published on

Talk to TW'ers in Brazil, focussing on code quality and understanding what that means.

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

  • Be the first to like this

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

No notes for slide

Thoughtworks Brazil, Code Quality

  1. 1. Ola.  
  2. 2. You’re  making  me     refactor.  You  won’t   like  me   when  I   refactor  
  3. 3. Refactoring?  
  4. 4. a  change  made  to  the  internal   structure  of  so=ware  to  make  it   easier  to  understand  and  cheaper   to  modify  without   changing  its   observable  behavior  ThoughtWorks  
  5. 5.  Dont  touch  anything  that  doesnt   have  coverage.  Otherwise,  youre  not  refactoring;   youre  just  changing  shit  
  6. 6. a  change  made  to  the  internal   structure  of  so=ware  to  make  it   easier  to   understand  and   cheaper  to   modify  without  changing   its  observable  behavior  ThoughtWorks  
  7. 7. SomeHmes  it  just  feels  right.  
  8. 8. Step  1:  Measure  the   toxicity.  
  9. 9. Smells  in  the  code  
  10. 10. CyclomaHc  Complexity  5  to  7  is  decent  for  most  ruby  code  
  11. 11. Saikuro  
  12. 12. Assignments,  Branches,  Calls     with  Flog  Watch  for  scores  greater  than  40  
  13. 13. Flog  
  14. 14. DuplicaHon  with  Flay  Watch  for  scores  greater  than  30  
  15. 15. Control  Couples  and  more     with  Reek  Simulated  Polymorphism  Feature  Envy  UHlity  Methods  
  16. 16. LinHng  with  Dust/Nitpick  JSLint  for  Ruby  
  17. 17. Common  smells     in  Ruby    
  18. 18. PrimiHve  Obsession  
  19. 19. Feature  Envy  
  20. 20. Meta-­‐programming   Keep  it  simple.     Keep  it  declaraHve  
  21. 21. Toxicity  is  more  than  code  smells  
  22. 22. “The  real  problem  I  have  with  the  CK  suite  and  similar  metrics  is  that  they  only  measure  a  single  module  (or  class  in  this  case).    I  claim  that  the  quality  of  the  design  of  a  system  is  not  something  that  can  be  determined  by  looking  at  individual  classes.    It  is  conceivable  that  every  class  in  a  system  could  be  considered  reasonable  by  whatever  single-­‐class  metrics  are  being  used,  but  the  overall  design  is  considered  bad.”  Ewan  Tempero:  A  Research  Agenda   hDp://www.cs.auckland.ac.nz/~ewan/  
  23. 23. DEPENDENCY  
  24. 24. Tangles  
  25. 25. Step  2:  Make  it  visible  
  26. 26. Treemaps  (Max  CC)  hbp://mbostock.github.com/protovis/  
  27. 27. Treemaps  
  28. 28. Dependency  matrix  
  29. 29. Step  3:  Agree  on  the  fix  
  30. 30. Step  4:      Go  fix  it  
  31. 31. Obrigado  

×