Slide 1

Slide 1 text

June 3rd 2013 - RefTest 2013 - (XP2013) Javier Pérez, Alessandro Murgia, Serge Demeyer A Proposal for fixing Design Smells Using Software Refactoring History

Slide 2

Slide 2 text

Only Simple Refactorings! How do we refactor? Tools?

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

How should we refactor? Recipes! Only textual descriptions! “Bad Smells in Code” chapter 3 Disharmonies chapters 5, 6, 7 Cheatsheet “Smells to Refactorings”

Slide 5

Slide 5 text

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()

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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!

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Refactoring Strategy Mining Strategies

Slide 11

Slide 11 text

Mining Specifications V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring Strategy S1 ... Sn R1 ... Rn Available Mature Tools Our goal

Slide 12

Slide 12 text

Available Tools: Design Smell Detection InCode / InFusion http://www.intooitus.com/

Slide 13

Slide 13 text

Available Tools: Refactoring Detection Ref-Finder https://webspace.utexas.edu/kp9746/www/reffinder/

Slide 14

Slide 14 text

Change-based Refactoring Detection ChEOPSJ http://win.ua.ac.be/~qsoeten/other/cheopsj

Slide 15

Slide 15 text

Key Concepts

Slide 16

Slide 16 text

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 ! !

Slide 17

Slide 17 text

June 3rd 2013 - RefTest 2013 - (XP2013) Javier Pérez, Alessandro Murgia, Serge Demeyer A Proposal for fixing Design Smells Using Software Refactoring History