1 / 59

Code Smell Research: History and Future Directions

Code Smell Research: History and Future Directions. Nikolaos Tsantalis Computer Science & Software Engineering. Preventive Software Maintenance. Changes aiming to improve the future maintainability and reliability of the software system. Why is it so necessary?. Software aging.

rodd
Download Presentation

Code Smell Research: History and Future Directions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Smell Research:History and Future Directions Nikolaos Tsantalis Computer Science & Software Engineering Second PLOW Installment - March 5, 2014

  2. Preventive Software Maintenance Changesaiming to improvethe futuremaintainabilityand reliabilityof the software system. Why is it so necessary? Second PLOW Installment - March 5, 2014

  3. Software aging Refactoring

  4. The Genesis 1992 • Refactoring Object-oriented Frameworks, University of Illinois at Urbana-Champaign • Introduced the concept of refactorings as behavior-preserving program restructuring operations. • Introduced the concept of preconditions as conditions that should be examined to determine whether a refactoring can be applied safely. Second PLOW Installment - March 5, 2014

  5. The Past 1999 Second PLOW Installment - March 5, 2014

  6. Martin FowlerRefactoring Duplicated Code: “If you see the same code structure in more than one place, … find a way to unify them.” Second PLOW Installment - March 5, 2014

  7. The Past 2001 1999 Second PLOW Installment - March 5, 2014

  8. Frank Simon, Claus LewerentzMetrics Based Refactoring CSMR Most Influential Paper Award Second PLOW Installment - March 5, 2014

  9. The Past 2002 2001 1999 Second PLOW Installment - March 5, 2014

  10. Eva van Emden, Leon MoonenAssuring Software Quality by Code Smell Detection WCRE Most Influential Paper Award jCosmo Second PLOW Installment - March 5, 2014

  11. The Past 2003 2002 2001 1999 Second PLOW Installment - March 5, 2014

  12. Tom Tourwé, Tom MensLogic Meta Programming Code smell definition for Inappropriate Interface inappropriateInterface(?class,?interface,?subclasses) :- findall(<?itf,?scs>, commonSubclassInterface(?class,?itf,?scs), ?result), removeDuplicates(?result,?nodups), member(<?interface,?subclasses>,?nodups) Second PLOW Installment - March 5, 2014

  13. The Past 2005 2003 2002 2001 1999 Second PLOW Installment - March 5, 2014

  14. RaduMarinescuDetection Strategies Second PLOW Installment - March 5, 2014

  15. The Past 2008 2005 2003 2002 2001 1999 Second PLOW Installment - March 5, 2014

  16. Mel O’Keeffe, Mel Ó CinnéideSearch-based Refactoring • Treat the improvement of object-oriented design as a search problem in the space of alternative designs • The movein the search space is achieved by modeling refactorings (inheritance-related) • Apply search algorithms using QMOOD as the fitness function (rank alternative designs) • The outcome is a sequence of refactoringsleading to the optimal design Second PLOW Installment - March 5, 2014

  17. The Past 2009 2008 2005 2003 2002 2001 1999 Second PLOW Installment - March 5, 2014

  18. NaouelMoha, Yann-GaëlGuéhéneucDECOR Second PLOW Installment - March 5, 2014

  19. Second PLOW Installment - March 5, 2014

  20. F. Palomba , G. Bavota, M. Di PentaHIST Why don’t we use historical information to find code smells? ACM Distinguished Paper Award ASE 2013 Second PLOW Installment - March 5, 2014

  21. Code smells + Change history Many code smell definitions are based on historical change information • Shotgun Surgery: When every time you make a kind of change, you have to make a lot of little changes to a lot of different classes. • Parallel Inheritance Hierarchies: When every time you make a subclass of one class, you also have to make a subclass of another. Patterns of changes repeated over time Second PLOW Installment - March 5, 2014

  22. Association Rule Discoveryin the Change History Second PLOW Installment - March 5, 2014

  23. Aiko Yamashita, Leon MoonenInter-smell Relations What are the interactions among code smells and how they affect maintenance? ICSE 2013 Second PLOW Installment - March 5, 2014

  24. Empirical Study design • 12 code smells • 6 Professional developers were hired to implement change requests • 4 medium-sized Java systems with known code smells • 4 weeks of development • Daily interviews and think-aloud sessions Second PLOW Installment - March 5, 2014

  25. Code Smell Relationships Second PLOW Installment - March 5, 2014

  26. The Other Side of the Coin Refactoring Opportunities Code Smells LIMITATION Second PLOW Installment - March 5, 2014

  27. Refactoring Opportunities Advantages: • Feasibleand behavior preserving solutionsto design problems • Ranking and prioritizing solutions based on their expected effect on design quality • A holisticapproach for preventive maintenance Second PLOW Installment - March 5, 2014

  28. Holistic solution TSE 2004 • Identify places where software should be refactored (known as bad smells). • Determine which refactoring(s) should be applied to the identified places. • Guarantee that the applied refactoring preserves behavior. • Apply the refactoring. • Assess the effect of the refactoring on quality characteristics of the software. • Maintain the consistency between the refactored code and other software artifacts. Second PLOW Installment - March 5, 2014

  29. The history of refactoring opportunities 2009 Second PLOW Installment - March 5, 2014

  30. #1 Misallocatedbehavior in classes Tsantalis & Chatzigeorgiou IEEE TSE, 2009 Second PLOW Installment - March 5, 2014

  31. The history of refactoring opportunities 2009 2010 Second PLOW Installment - March 5, 2014

  32. #2 Conditional logicvs. Polymorphism state StateA StateB Context Context State • + method() { • state.method(); • } • + method() { • } +method() { } +method() { } +method() - type : int -STATE_A : int = 1 -STATE_B : int = 2 -state : int -STATE_A : int = 1 -STATE_B : int = 2 • ifstate== STATE_A • else • ifstate== STATE_B • doStateA(); • doStateB(); Tsantalis & Chatzigeorgiou JSS, 2010 Second PLOW Installment - March 5, 2014

  33. The history of refactoring opportunities 2009 2010 2011 Second PLOW Installment - March 5, 2014

  34. #3 Long & Complex methods Tsantalis & Chatzigeorgiou JSS, 2011 Second PLOW Installment - March 5, 2014

  35. The history of refactoring opportunities 2009 2010 2011 2012 Second PLOW Installment - March 5, 2014

  36. #4 Large & Complex classes 19 methods 11 fields 70 methods 15 fields 900 LOC Bavota et al. JSS, 2011 Fokaefs et al. JSS, 2012 Second PLOW Installment - March 5, 2014

  37. The history of refactoring opportunities 2009 2010 2011 2012 2013 Second PLOW Installment - March 5, 2014

  38. #5 Generalization of common interfaces or functionalities Liu et al. AutomSoftwEng, 2013 Second PLOW Installment - March 5, 2014

  39. The history of refactoring opportunities 2014 2009 2010 2011 2012 2013 Second PLOW Installment - March 5, 2014

  40. #6 Software Clones Krishnan & Tsantalis CSMR-WCRE, 2014 Second PLOW Installment - March 5, 2014

  41. TOOLS Second PLOW Installment - March 5, 2014

  42. Since the beginning of 2011 … 20+ academic licenses 5,000 marketplace installations 8,000 applied refactorings Second PLOW Installment - March 5, 2014

  43. State-of-the-art commercial tools Live code smell detection Smart visualizations Technical debt assessment Computer-aided refactoring Second PLOW Installment - March 5, 2014

  44. So, tools are adopted What’s next? Management of Code Smells Second PLOW Installment - March 5, 2014

  45. Motivation Not all code smells are equally important Why should we refactor a piece of code that neverchanges? a piece of code that is not used? a piece of code that is not involved in bugs? Second PLOW Installment - March 5, 2014

  46. Technical debtmanagement • “Debt”is the effect of incomplete, immature, or inadequate maintenance activities • Delayed tasks may bring a short-term benefit (higher productivity, shorter release time) • Might have to be paid back in the future with “Interest” (increased effort) • “Principal” is the effort to pay off the debt Second PLOW Installment - March 5, 2014

  47. Clone management • Tracking clones as project evolves • Verifying the consistent modification of clones • Updating clones and groups as project evolves • Assessing the harmfulness of clones Second PLOW Installment - March 5, 2014

  48. M. Mondal, C. Roy Why don’t we use historical information to rank clones for refactoring? CSMR-WCRE 2014 Second PLOW Installment - March 5, 2014

  49. Similarity Preserving Change Pattern If the clones co-change by preserving their similarity, they should have higher priority for refactoring Second PLOW Installment - March 5, 2014

  50. Second PLOW Installment - March 5, 2014

More Related