Preventive Software Maintenance: The Past, the Present, the ...

Preventive Software Maintenance: The Past, the Present, the ...

Code Smell Research: History and Future Directions Nikolaos Tsantalis Computer Science & Software Engineering Second PLOW Installment - March 5, 2014 1 Preventive Software Maintenance Changes aiming to improve the future maintainability and reliability of the

software system. Why is it so necessary? Second PLOW Installment - March 5, 2014 2 Software aging Refactoring 3

The Genesis Refactoring Object-oriented Frameworks, University of Illinois at Urbana-Champaign 1992 Introduced the concept of refactorings as behaviorpreserving 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 4 The Past 1999 Second PLOW Installment - March 5, 2014 5 Martin Fowler

Refactoring 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 6 The Past

1999 2001 Second PLOW Installment - March 5, 2014 7 Frank Simon, Claus Lewerentz Metrics Based Refactoring CSMR Most Influential

Paper Award Second PLOW Installment - March 5, 2014 8 The Past 1999 2001

2002 Second PLOW Installment - March 5, 2014 9 Eva van Emden, Leon Moonen Assuring Software Quality by Code Smell Detection WCRE Most Influential Paper Award

jCosmo Second PLOW Installment - March 5, 2014 10 The Past 1999 2001

2002 2003 Second PLOW Installment - March 5, 2014 11 Tom Tourw, Tom Mens Logic Meta Programming Code smell definition for Inappropriate Interface inappropriateInterface(?class,?interface,?subclasses) :findall(,

commonSubclassInterface(?class,?itf,?scs), ?result), removeDuplicates(?result,?nodups), member(,?nodups) Second PLOW Installment - March 5, 2014 12 The Past 1999

2001 2002 2003 2005 Second PLOW Installment - March 5, 2014 13

Radu Marinescu Detection Strategies Second PLOW Installment - March 5, 2014 14 The Past 1999 2001

2002 2003 2005 Second PLOW Installment - March 5, 2014 2008 15

Mel OKeeffe, Mel Cinnide Search-based Refactoring Treat the improvement of object-oriented design as a search problem in the space of alternative designs The move in 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 refactorings leading

to the optimal design Second PLOW Installment - March 5, 2014 16 The Past 1999 2001 2002

2003 2005 Second PLOW Installment - March 5, 2014 2008 2009 17

Naouel Moha, Yann-Gal Guhneuc DECOR Second PLOW Installment - March 5, 2014 18 Second PLOW Installment - March 5, 2014 19

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

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

21 Association Rule Discovery in the Change History Second PLOW Installment - March 5, 2014 22 Aiko Yamashita, Leon Moonen Inter-smell Relations What are the interactions among code smells

and how they affect maintenance? ICSE 2013 Second PLOW Installment - March 5, 2014 23 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 24 Code Smell Relationships Second PLOW Installment - March 5, 2014

25 The Other Side of the Coin Refactoring Opportunities Code Smells LIM N

O I T A T I Second PLOW Installment - March 5, 2014 26 Refactoring Opportunities Advantages:

Feasible and behavior preserving solutions to design problems Ranking and prioritizing solutions based on their expected effect on design quality A holistic approach for preventive maintenance Second PLOW Installment - March 5, 2014 27 Holistic solution

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

28 The history of refactoring opportunities 2009 Second PLOW Installment - March 5, 2014 29 #1 Misallocated behavior in classes

Tsantalis & Chatzigeorgiou IEEE TSE, 2009 Second PLOW Installment - March 5, 2014 30 The history of refactoring opportunities 2009 2010 Second PLOW Installment - March 5, 2014

31 #2 Conditional logic vs. Polymorphism Context - State state int

type : :int STATE_A : int = 1 STATE_B : int = 2 stat e +method( ) + method() { state.method();

if state == } STATE_A doStateA(); else doStateB(); if state == }STATE_B StateA

StateB +method() { +method() { } }

Tsantalis & Chatzigeorgiou Second PLOW Installment - March 5, 2014 JSS, 2010 32 The history of refactoring opportunities 2009 2010 2011 Second PLOW Installment - March 5, 2014

33 #3 Long & Complex methods Tsantalis & Chatzigeorgiou JSS, 2011 Second PLOW Installment - March 5, 2014 34 The history of refactoring opportunities

2009 2010 2011 2012 Second PLOW Installment - March 5, 2014 35 #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 36 The history of refactoring opportunities 2009 2010 2011 2012 2013 Second PLOW Installment - March 5, 2014

37 #5 Generalization of common interfaces or functionalities Liu et al. Autom Softw Eng, 2013 Second PLOW Installment - March 5, 2014 38 The history of refactoring opportunities

2009 2010 2011 2012 2013 2014 Second PLOW Installment - March 5, 2014 39 #6 Software Clones Krishnan & Tsantalis CSMR-WCRE, 2014 Second PLOW Installment - March 5, 2014

40 TOOLS Second PLOW Installment - March 5, 2014 41 Since the beginning of 2011 20+ academic licenses 5,000 marketplace installations

8,000 applied refactorings Second PLOW Installment - March 5, 2014 42 State-of-the-art commercial tools Live code smell detection Smart visualizations Technical debt assessment Computer-aided refactoring

Second PLOW Installment - March 5, 2014 43 So, tools are adopted Whats next? Management of Code Smells Second PLOW Installment - March 5, 2014 44

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

management 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 46

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 47 M. Mondal, C. Roy Why dont we use historical information to rank clones for refactoring? CSMR-WCRE 2014 Second PLOW Installment - March 5, 2014

48 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 49 Second PLOW Installment - March 5, 2014

50 Research direction #1 Alternative code smell detection So far, we used Static source code analysis Semantic analysis Change history analysis What about developer collaboration patterns

the history of bug resolutions Second PLOW Installment - March 5, 2014 51 In other words... MSR for detecting code smells and refactoring opportunities Second PLOW Installment - March 5, 2014 52

Research direction #2 Risk Management Every code smell involves a certain risk for future maintainability What is the risk of leaving a code smell in the system? Second PLOW Installment - March 5, 2014

53 Risk Assessment Likelihood of occurrence of the risky event Exposure of the system to the event Consequence of the event Risk = Likelihood Exposure Consequence Second PLOW Installment - March 5, 2014 54

Likelihood estimation Risky events changes driven by code smells Ex. 1: Fixing the same bug in a clone group Ex. 2: Making a method more envy to another class Intuition: code that changes frequently due to a design flaw imposes a high risk to the maintainability of a system Likelihood proneness to code smell driven changes (estimated from the history of changes)

Second PLOW Installment - March 5, 2014 55 Exposure estimation Intuition: the more extensively a module is used, the more extensive the propagation of code smell driven changes to dependent modules Exposure the number and strength of incoming dependencies (estimated from static and dynamic analysis)

Second PLOW Installment - March 5, 2014 56 Consequence estimation Consequence cost of code smell driven changes (effort, time, money). From the opposite perspective: Consequence effect of removing the code smell. Estimated by computing the impact of the

corresponding refactoring on metrics. Second PLOW Installment - March 5, 2014 57 Research direction #3 Refactoring Scheduling Given a set of different types of refactoring opportunities in a software system How can we find an order that maximizes the number of applied refactorings?

Conflicts Dependencies Second PLOW Installment - March 5, 2014 58 Visit our project at http://jdeodorant.com Second PLOW Installment - March 5, 2014 59

Recently Viewed Presentations

  • Revelation Chapter 15 - Bible Truth

    Revelation Chapter 15 - Bible Truth

    And they sing the song of Moses the servant of God, and the song of the Lamb, saying, Great and marvellous are thy works, Lord God Almighty; just and true are thy ways, thou King of saints. (Revelation 15:3)
  • Sahel Lake Tanganyika Nile River Desertification Congo River

    Sahel Lake Tanganyika Nile River Desertification Congo River

    Definitions. Sahel: a dry, semi-arid region south of the Sahara Desert covering almost 1,800,000 square miles that is slowly turning into desert land.It serves as a transition region between the harsh desert to the north and the grasslands and rain...
  • Aircraft Instruments Attitude Indicator  Determines the position of

    Aircraft Instruments Attitude Indicator Determines the position of

    Aircraft Instruments Attitude Indicator Determines the position of the aircraft in relationship to the horizon Red/orange marker represents wings Blue and brown ball represents the sky and ground Airspeed Indicator Tells you how fast you are moving through the air...
  • SKIF-GRID SUPERCOMPUTING PROJECT OF THE UNION STATE OF

    SKIF-GRID SUPERCOMPUTING PROJECT OF THE UNION STATE OF

    Infiniband QDR) New approach to monitoring and management of the supercomputer Combining standard CPUs and accelerators in computational nodes of the supercomputer Spring'2008: SKIF Series 4 — How To? Summer'2008: SKIF Series 4 — Know How! ... Designed by the...
  • Differences in Culture McDonalds in India

    Differences in Culture McDonalds in India

    Differences in Culture:McDonald's in India. By: Jessica Weimerskirk. What is Culture? Culture - A system of values and norms that are shared among a group of people that constitutes a way of living. Dealing with everyday life.
  • National 5 and Higher English - Larbert High School

    National 5 and Higher English - Larbert High School

    RUAE 30%. Critical Reading 40%. 2x Essays. Higher - 1300 words. National 5 - 1000 words. 1x Persuasive/Discursive. 1x Creative/Personal. Newspaper article and close reading style questions. Understanding. Analysis. Evaluation. 1x Critical essay on a text. 1x Textual Analysis paper...
  • Organizational Design, Diagnosis, and Development

    Organizational Design, Diagnosis, and Development

    Organizational Design, Diagnosis, and Development ... Woodward came to believe technology determined structure Mass is more mechanistic Unit and process are more organic Hierarchy increases from unit to mass to process Technical Complexity & Structure for Effective Firms Technical Complexity...
  • Clinician Smoking Cessation Intervention for Adults

    Clinician Smoking Cessation Intervention for Adults

    Health Care Providers are sometimes required to obtain a Business Associate Agreement (BAA) if a third party vendor is performing a function or service for a facility & Affiliates that requires the vendor to have access to health information to...