Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Proposal for fixing Design Smells Using Software Refactoring History

A Proposal for fixing Design Smells Using Software Refactoring History

Can complex composed refactorings be offered to developers through development tools? In this position paper we propose an approach that may help developers improving the design of a software system by reusing complex refactorings that were useful in the past. We claim the refactoring recipes performed for fixing design smells can be mined from source code changes’ history and formalized so they are directly reapplicable with a refactoring tool. Our proposal is supported by our former work and by other available tools. Presented at RefTest 2013 (http://reftest2013.wordpress.com).

Javier Pérez

June 03, 2013
Tweet

More Decks by Javier Pérez

Other Decks in Research

Transcript

  1. June 3rd 2013 - RefTest 2013 - (XP2013) Javier Pérez,

    Alessandro Murgia, Serge Demeyer A Proposal for fixing Design Smells Using Software Refactoring History
  2. What refactorings we use? ! Eclipse Usage Data Collector -

    http://www.eclipse.org/org/usagedata/results.php? kind=command&sort=element http://stackoverflow.com/questions/1804839/eclipse-most-useful-refactorings
  3. How should we refactor? Recipes! Only textual descriptions! “Bad Smells

    in Code” chapter 3 Disharmonies chapters 5, 6, 7 Cheatsheet “Smells to Refactorings”
  4. PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document printDocument(): void

    lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document Complex Refactoring Processes ✤ Feature Envy: PrinterServer.formatSummary() ✤ Strategy: move method from PrintServer to Document ✤ Plan: ✤ rename Document.formatSummary() ✤ move PrintServer.formatSummary()
  5. Refactoring Strategy Refactoring Plans Refactoring Planner Refactoring Strategy Vn current

    Refactoring Plans Refactoring Planner Refactoring Tool Refactoring Strategy Vn+1 improved design Vn current Refactoring Strategies and Plans “Refactoring Planning for Design Smell Correction in Object-Oriented Software” Javier Pérez; PhD Thesis, July 2011, University of Valladolid
  6. Remove Data Class Strategy remove-data-class all-sts (class) remove-data-class reorganize-class (class)

    remove-class (class) remove-data-class trivial (class) refactoring alt apply strategy (refact.) strategy (smell) remove-data-class clean-class (class) encapsulate-field (field, getter-name, setter-name) encapsulate-fields non-private (class) remove-getters unused (class) remove-setters unsued (class) remove-feature-envy move-method-to-envied-class (method, env-class) move-method all-sts (method, tgt-class, reference) remove-method (accessor) remove-data-class move-fe-methods (class) remove-data-class move-client-methods (class) • preconditions • control structures • strategies invocation • code queries • metrics • user queries
  7. Remove Data Class Plan apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute,! gettypeinfolabels)!

    apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute,! getframelabels, to, org.jwebap.asm.attrs, stackmapframe,! through, frame, keeping-delegate, false)! apply-refactoring:! ! show-method (org.jwebap.asm.attrs, stackmapattribute, writetypeinfo)! apply-refactoring:! ! move-method (from, org.jwebap.asm.attrs, stackmapattribute,! writeframe, to, org.jwebap.asm.attrs, stackmapframe,! through, frame, keeping-delegate, false)! apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute, asmify)! apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute,! declarelabel)! apply-refactoring:! ! show-method (org.jwebap.asm.util.attrs, asmstackmapattribute,! asmifytypeinfo)! apply-refactoring:! ! move-method (from, org.jwebap.asm.util.attrs, asmstackmapattribute, ! asmify, to, org.jwebap.asm.attrs, stackmapframe,! through, f keeping-delegate, false)! apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, label,! getlabel, setlabel)! apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, locals,! getlocals, setlocals)! apply-refactoring:! ! encapsulate-field (org.jwebap.asm.attrs, stackmapframe, stack, ! getstack, setstack)! apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlabel) (SETTER)! apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setlocals)(SETTER)! apply-refactoring:! ! remove-method(org.jwebap.asm.attrs, stackmapframe, setstack) (SETTER)! apply-remove-smell:!remove-data-class (org.jwebap.asm.attrs, stackmapframe) cleanclass!
  8. Refactoring Strategy Refactoring Plans Refactoring Planner Refactoring Strategy Vn current

    Refactoring Plans Refactoring Planner Refactoring Tool Refactoring Strategy Vn+1 improved design Vn current Mining Strategies “Refactoring Planning for Design Smell Correction in Object-Oriented Software” Javier Pérez; PhD Thesis, July 2011, University of Valladolid
  9. Mining Specifications V1 ... Vn Refactoring Finder Smell Finder Strategy

    Miner Refactoring Strategy S1 ... Sn R1 ... Rn Available Mature Tools Our goal
  10. Key Concepts • There is a need to implement big

    refactorings ! • Big refactorings should be implemented “empirically” - with recipes ! • Solution: Refactoring Strategies + Refactoring Plans ! • Strategy mining: Smell detection + Refactoring detection ! !
  11. June 3rd 2013 - RefTest 2013 - (XP2013) Javier Pérez,

    Alessandro Murgia, Serge Demeyer A Proposal for fixing Design Smells Using Software Refactoring History