SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
2008. 12. 5                       TOKYO INSTITUTE OF TECHNOLOGY
                                  DEPARTMENT OF COMPUTER SCIENCE
APSEC 2008




   Detecting Occurrences
        of Refactoring
    with Heuristic Search
Shinpei Hayashi Yasuyuki Tsuda            Motoshi Saeki

              Department of Computer Science
               Tokyo Institute of Technology
                           Japan
Abstract
   Detecting Occurrences of Refactoring
    − Detecting where to and what kinds of refactoring
      were performed between two ver. of programs
    − From version archives such as CVS/Subversion
   with Heuristic Search
    − We use a graph search technique for detecting
      impure refactorings
   Results
    − (Semi-)automated tools have been developed
    − We have a simple case study
Background
   It is important to reduce the cost for
    understanding the changes of a program,
    which is continually modified
I have to follow the changes of L...
  What do the changes mean?               ver. 123
                                                 modify

                                         ver. 124
                        use     Program L
                                (a library)
                                                     FOSS project
          Program S                    (FOSS: Free/Open Source Software)
                                                                           3
Aim
   Categorization of modifications is useful
    − Detecting refactorings between two versions of a
      program

     The changes are:
     Extract Method +                 ver. 123
     Move Method + α!
                                             modify

                                       ver. 124
                        use   Program L
                              (a library)
                                                  FOSS project
         Program S                 (FOSS: Free/Open Source Software)
                                                                       4
Detecting Refactorings
   Related work
    − with software metrics [Demeyer 2000]
    − by checking pre/post-conditions of source
      code properties [Weißgerber 2006]


   Key issue
    − detecting impure refactorings [Görg 2005]
      • refactoring + refactoring
      • refactoring + other modifications
                                                  5
Motivating Scenario
   Example from Fowler’s book [Fowler 1999]
                Extract               Move
        n0      Method      n1       Method      nm

     Customer             Customer            Customer
     statement()        statement()           statement()
                     getCharge(Rental)
                                                Rental
       Rental              Rental
                                              getCharge()


                                                            6
Scenario: Lost of States
Version
Archive
           Rold                                                  Rnew
                                           lose
 commit                                    intermediate state         commit

                        Extract                        Move
            n0          Method          n1            Method       n2
          Customer                    Customer
                                                                Customer
                                     statement()
          statement()                                           statement()
                                  getCharge(Rental)

                                                                  Rental
            Rental                     Rental
                                                                getCharge()

                                                                               7
Scenario: Diffs between revs
   Hard to detect refactorings via mixed differences
    − Considering intermediate states is required


Version
Archive
           Rold                                      Rnew
    Customer
                  1. Some code fragments in           Customer
    statement()      Customer#statement is removed    statement()
                  2. a method invocation to
                     Rental#getCharge is added to       Rental
      Rental
                     statement
                                                      getCharge()
                  3. Rental#getCharge is added
                           Mixed differences
                                                                    8
Our Approach
   Generating intermediate states by actually
    applying refactorings to the program
   Finding an appropriate path from Rold (= n0) to
    Rnew (= nm) by a graph search technique
                    States (nodes): versions of the program
                    Transitions (edges): refactoring operations




       n0                                              nm
Initial state                                        Final state
    (Rold)                                             (Rnew)
                                                                  9
Procedure
1. Find likely refactorings
2. Evaluate the distance to the nm
3. Apply the best one and generate new state




                6
        n0          4                 nm
Initial state                        Final state
     (Rold)                           (Rnew)
                8                              10
Procedure
1. Find likely refactorings
2. Evaluate the distance to the nm
3. Apply the best one and generate new state

       Terminate if the new state almost equals to Rnew

                6
                                3
        n0                              2       nm
Initial state                                  Final state
     (Rold)                                      (Rnew)
                8              3                          11
Efficient Search
1.   How to find candidates of refactorings?
     − They should be similar to the changes for nm

2.   How to evaluate them?
     − The best one should generate new state closer to nm

    We use structural differences between two states

                6
                                    3
        n0                                    2        nm
Initial state                                         Final state
     (Rold)                                            (Rnew)
                8                  3                            12
Structural Differences
   Calculated by comparing two AST
    − 4 types: add, remove, change, move
                            public class Customer {
public class Customer {
                                int id;
    int customerID;
                                String name;
    String name;
                                int[] phoneNum;
}
                            }



change(Customer, the name customerID, the name id)
add(FieldDeclaration int[] phoneNum, Customer)
…
                                                      13
Find New Refactorings
   By matching between diffs. (D) and modifications
    representing a refactoring operation (R)
     − if a subset of D matches a subset of R, the refactoring
       operation is expanded.
     − Matching likelihood: (# of matched modifications) / (# of R)

    The differences (D):                                                 nm
    remove(Block, Customer#statement)
    add(MethodInvocation, Rental#statement)
    change(Rental, the name “n1”, the name“n2”)
    …

    Extract Method (R):
    remove(Block, ClassA#method1)
                                                  Matching likelihood:
    add(MethodDeclaration, ClassA)
                                                  0.5 (1/2)                   14
Evaluation
   Using f(n, o) = g(n) + h(n) / α(o)
    − g(n): # of applied refactorings for obtaining n
    − h(n): the size of differences between n and nm
    − α(o): likelihood of o
   f(n2, o6) = 2 + 3 / (1/2) = 8
                                        o6
                                             α(o6) = 1/2
                                  n2
            o1
                 g(n2) = 2         o4   h(n2) = 3
      n0                                              nm
Initial State
                   o2        n1                      Goal State
    (Pold)    o3                  o5                   (Pnew)
                                                              15
Supporting Tools
   Expanding and evaluating candidates of
    refactorings with REUSAR (implemented)
    − Input: Two versions of Java source code
    − Output: Candidates of refactorings with priority
    − Calculating differences with XMLdiff (an existing tool)


   Applying refactorings by Eclipse
    − Checking pre/post-conditions
    − Modifying source code
                                                                16
Case Study
   Applying our technique to an
    existing version archive, REUSAR
    (supporting tool in this study)



                           1. Rename Method
        R1796             2. Remove Parameter        R1799

     DistanceCalculator                         DistanceCalculator
calculateDistance(List<Diff>)                     calcDistance()
                                                                     17
Case Study: Result
R1796                                                     R1799
             4   Rename
                 Method
                              n1          4    Remove
                                              Parameter

 n0          4    Remove
                                                           n2
                 Parameter                7    Extract
                                               Method

             8    Extract
                  Method




   Our technique is effective
    − It can correctly detect impure refactorings which were
      actually performed
    − Prioritizing the candidates reduces # of applications of
      refactoring operations                                     18
Conclusion
   Summary
    − Detecting refactorings by a graph search,
      based on heuristics with structural
      differences between two programs
    − Our technique can detect impure
      refactorings
   Future Work
    − Tool integration
    − Evaluation: larger-scale case study
                                                  19

Contenu connexe

Tendances

Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source CodeShinpei Hayashi
 
Oop02 6
Oop02 6Oop02 6
Oop02 6schwaa
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interfaceHao Chai
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Fahad Cheema
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...André Oriani
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingRuymán Reyes
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)Prashant Sharma
 

Tendances (19)

Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source Code
 
GCC RTL and Machine Description
GCC RTL and Machine DescriptionGCC RTL and Machine Description
GCC RTL and Machine Description
 
Oop02 6
Oop02 6Oop02 6
Oop02 6
 
Basics of building a blackfin application
Basics of building a blackfin applicationBasics of building a blackfin application
Basics of building a blackfin application
 
Syntutic
SyntuticSyntutic
Syntutic
 
Boost.Dispatch
Boost.DispatchBoost.Dispatch
Boost.Dispatch
 
Extending and scripting PDT
Extending and scripting PDTExtending and scripting PDT
Extending and scripting PDT
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interface
 
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
Resource to Performance Tradeoff Adjustment for Fine-Grained Architectures ─A...
 
Functions
FunctionsFunctions
Functions
 
SRAVANByCPP
SRAVANByCPPSRAVANByCPP
SRAVANByCPP
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous Computing
 
ICPC08b.ppt
ICPC08b.pptICPC08b.ppt
ICPC08b.ppt
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)
 
Unit 8
Unit 8Unit 8
Unit 8
 
Cpp reference card
Cpp reference cardCpp reference card
Cpp reference card
 
GCC
GCCGCC
GCC
 

En vedette

Understanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring EffectsUnderstanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring EffectsShinpei Hayashi
 
Visualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored MapVisualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored MapTakanori Ugai
 
Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...Shinpei Hayashi
 
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature LocationGuiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature LocationShinpei Hayashi
 
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security RequirementsModeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security RequirementsShinpei Hayashi
 
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept AnalysisFeature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept AnalysisHiroshi Kazato
 
Incremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source CodeIncremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source CodeHiroshi Kazato
 
Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...Shinpei Hayashi
 
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQMHow Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQMShinpei Hayashi
 
Historef: A Tool for Edit History Refactoring
Historef: A Tool  for Edit History RefactoringHistoref: A Tool  for Edit History Refactoring
Historef: A Tool for Edit History RefactoringShinpei Hayashi
 
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements AnalysisEstablishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements AnalysisShinpei Hayashi
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Shinpei Hayashi
 
Toward Structured Location of Features
Toward Structured Location of FeaturesToward Structured Location of Features
Toward Structured Location of FeaturesHiroshi Kazato
 
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint SatisfactionClass Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint SatisfactionShinpei Hayashi
 
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」Takashi Kobayashi
 

En vedette (15)

Understanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring EffectsUnderstanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring Effects
 
Visualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored MapVisualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored Map
 
Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...
 
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature LocationGuiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature Location
 
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security RequirementsModeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
 
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept AnalysisFeature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept Analysis
 
Incremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source CodeIncremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source Code
 
Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...
 
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQMHow Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
 
Historef: A Tool for Edit History Refactoring
Historef: A Tool  for Edit History RefactoringHistoref: A Tool  for Edit History Refactoring
Historef: A Tool for Edit History Refactoring
 
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements AnalysisEstablishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
 
Toward Structured Location of Features
Toward Structured Location of FeaturesToward Structured Location of Features
Toward Structured Location of Features
 
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint SatisfactionClass Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
 
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
 

Similaire à Detecting Occurrences of Refactoring with Heuristic Search

Webinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBWebinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBMongoDB
 
Code Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeCode Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeKamiya Toshihiro
 
HA Hadoop -ApacheCon talk
HA Hadoop -ApacheCon talkHA Hadoop -ApacheCon talk
HA Hadoop -ApacheCon talkSteve Loughran
 
Consolidated shared indexes in real time
Consolidated shared indexes in real timeConsolidated shared indexes in real time
Consolidated shared indexes in real timeJeff Mace
 
Framework Engineering Revisited
Framework Engineering RevisitedFramework Engineering Revisited
Framework Engineering RevisitedYoungSu Son
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers TrainingJan Gregersen
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers TrainingJan Gregersen
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practiceDocker, Inc.
 
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...Databricks
 
CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureMasud Rahman
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVMJohn Lee
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution立偉 馬
 
DO-178C OOT supplement: A user's perspective
DO-178C OOT supplement: A user's perspectiveDO-178C OOT supplement: A user's perspective
DO-178C OOT supplement: A user's perspectiveAdaCore
 
Madeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareMadeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareESUG
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012Steven Francia
 

Similaire à Detecting Occurrences of Refactoring with Heuristic Search (20)

Webinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBWebinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDB
 
Code Difference Visualization by a Call Tree
Code Difference Visualization by a Call TreeCode Difference Visualization by a Call Tree
Code Difference Visualization by a Call Tree
 
HA Hadoop -ApacheCon talk
HA Hadoop -ApacheCon talkHA Hadoop -ApacheCon talk
HA Hadoop -ApacheCon talk
 
Consolidated shared indexes in real time
Consolidated shared indexes in real timeConsolidated shared indexes in real time
Consolidated shared indexes in real time
 
Generator
GeneratorGenerator
Generator
 
SUBJECT
SUBJECTSUBJECT
SUBJECT
 
Framework Engineering Revisited
Framework Engineering RevisitedFramework Engineering Revisited
Framework Engineering Revisited
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers Training
 
OpenMI Developers Training
OpenMI Developers TrainingOpenMI Developers Training
OpenMI Developers Training
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
 
Assembler (2)
Assembler (2)Assembler (2)
Assembler (2)
 
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...
Ray: A Cluster Computing Engine for Reinforcement Learning Applications with ...
 
XS Oracle 2009 Just Run It
XS Oracle 2009 Just Run ItXS Oracle 2009 Just Run It
XS Oracle 2009 Just Run It
 
CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lecture
 
Android RenderScript on LLVM
Android RenderScript on LLVMAndroid RenderScript on LLVM
Android RenderScript on LLVM
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution
 
DO-178C OOT supplement: A user's perspective
DO-178C OOT supplement: A user's perspectiveDO-178C OOT supplement: A user's perspective
DO-178C OOT supplement: A user's perspective
 
Madeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable HardwareMadeo - a CAD Tool for reconfigurable Hardware
Madeo - a CAD Tool for reconfigurable Hardware
 
Applied Computer Science Concepts in Android
Applied Computer Science Concepts in AndroidApplied Computer Science Concepts in Android
Applied Computer Science Concepts in Android
 
MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012MongoDB, Hadoop and humongous data - MongoSV 2012
MongoDB, Hadoop and humongous data - MongoSV 2012
 

Plus de Shinpei Hayashi

Revisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change RecommendationRevisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change RecommendationShinpei Hayashi
 
An Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug LocalizationAn Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug LocalizationShinpei Hayashi
 
RefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for RefactoringRefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for RefactoringShinpei Hayashi
 
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?Shinpei Hayashi
 
The Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History SlicingThe Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History SlicingShinpei Hayashi
 
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source CodeChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source CodeShinpei Hayashi
 
Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2Shinpei Hayashi
 
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements AnalysisDetecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements AnalysisShinpei Hayashi
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いShinpei Hayashi
 

Plus de Shinpei Hayashi (9)

Revisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change RecommendationRevisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change Recommendation
 
An Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug LocalizationAn Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug Localization
 
RefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for RefactoringRefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for Refactoring
 
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
 
The Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History SlicingThe Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History Slicing
 
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source CodeChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
 
Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2
 
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements AnalysisDetecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘い
 

Dernier

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Detecting Occurrences of Refactoring with Heuristic Search

  • 1. 2008. 12. 5 TOKYO INSTITUTE OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE APSEC 2008 Detecting Occurrences of Refactoring with Heuristic Search Shinpei Hayashi Yasuyuki Tsuda Motoshi Saeki Department of Computer Science Tokyo Institute of Technology Japan
  • 2. Abstract  Detecting Occurrences of Refactoring − Detecting where to and what kinds of refactoring were performed between two ver. of programs − From version archives such as CVS/Subversion  with Heuristic Search − We use a graph search technique for detecting impure refactorings  Results − (Semi-)automated tools have been developed − We have a simple case study
  • 3. Background  It is important to reduce the cost for understanding the changes of a program, which is continually modified I have to follow the changes of L... What do the changes mean? ver. 123 modify ver. 124 use Program L (a library) FOSS project Program S (FOSS: Free/Open Source Software) 3
  • 4. Aim  Categorization of modifications is useful − Detecting refactorings between two versions of a program The changes are: Extract Method + ver. 123 Move Method + α! modify ver. 124 use Program L (a library) FOSS project Program S (FOSS: Free/Open Source Software) 4
  • 5. Detecting Refactorings  Related work − with software metrics [Demeyer 2000] − by checking pre/post-conditions of source code properties [Weißgerber 2006]  Key issue − detecting impure refactorings [Görg 2005] • refactoring + refactoring • refactoring + other modifications 5
  • 6. Motivating Scenario  Example from Fowler’s book [Fowler 1999] Extract Move n0 Method n1 Method nm Customer Customer Customer statement() statement() statement() getCharge(Rental) Rental Rental Rental getCharge() 6
  • 7. Scenario: Lost of States Version Archive Rold Rnew lose commit intermediate state commit Extract Move n0 Method n1 Method n2 Customer Customer Customer statement() statement() statement() getCharge(Rental) Rental Rental Rental getCharge() 7
  • 8. Scenario: Diffs between revs  Hard to detect refactorings via mixed differences − Considering intermediate states is required Version Archive Rold Rnew Customer 1. Some code fragments in Customer statement() Customer#statement is removed statement() 2. a method invocation to Rental#getCharge is added to Rental Rental statement getCharge() 3. Rental#getCharge is added Mixed differences 8
  • 9. Our Approach  Generating intermediate states by actually applying refactorings to the program  Finding an appropriate path from Rold (= n0) to Rnew (= nm) by a graph search technique States (nodes): versions of the program Transitions (edges): refactoring operations n0 nm Initial state Final state (Rold) (Rnew) 9
  • 10. Procedure 1. Find likely refactorings 2. Evaluate the distance to the nm 3. Apply the best one and generate new state 6 n0 4 nm Initial state Final state (Rold) (Rnew) 8 10
  • 11. Procedure 1. Find likely refactorings 2. Evaluate the distance to the nm 3. Apply the best one and generate new state Terminate if the new state almost equals to Rnew 6 3 n0 2 nm Initial state Final state (Rold) (Rnew) 8 3 11
  • 12. Efficient Search 1. How to find candidates of refactorings? − They should be similar to the changes for nm 2. How to evaluate them? − The best one should generate new state closer to nm  We use structural differences between two states 6 3 n0 2 nm Initial state Final state (Rold) (Rnew) 8 3 12
  • 13. Structural Differences  Calculated by comparing two AST − 4 types: add, remove, change, move public class Customer { public class Customer { int id; int customerID; String name; String name; int[] phoneNum; } } change(Customer, the name customerID, the name id) add(FieldDeclaration int[] phoneNum, Customer) … 13
  • 14. Find New Refactorings  By matching between diffs. (D) and modifications representing a refactoring operation (R) − if a subset of D matches a subset of R, the refactoring operation is expanded. − Matching likelihood: (# of matched modifications) / (# of R) The differences (D): nm remove(Block, Customer#statement) add(MethodInvocation, Rental#statement) change(Rental, the name “n1”, the name“n2”) … Extract Method (R): remove(Block, ClassA#method1) Matching likelihood: add(MethodDeclaration, ClassA) 0.5 (1/2) 14
  • 15. Evaluation  Using f(n, o) = g(n) + h(n) / α(o) − g(n): # of applied refactorings for obtaining n − h(n): the size of differences between n and nm − α(o): likelihood of o  f(n2, o6) = 2 + 3 / (1/2) = 8 o6 α(o6) = 1/2 n2 o1 g(n2) = 2 o4 h(n2) = 3 n0 nm Initial State o2 n1 Goal State (Pold) o3 o5 (Pnew) 15
  • 16. Supporting Tools  Expanding and evaluating candidates of refactorings with REUSAR (implemented) − Input: Two versions of Java source code − Output: Candidates of refactorings with priority − Calculating differences with XMLdiff (an existing tool)  Applying refactorings by Eclipse − Checking pre/post-conditions − Modifying source code 16
  • 17. Case Study  Applying our technique to an existing version archive, REUSAR (supporting tool in this study) 1. Rename Method R1796 2. Remove Parameter R1799 DistanceCalculator DistanceCalculator calculateDistance(List<Diff>) calcDistance() 17
  • 18. Case Study: Result R1796 R1799 4 Rename Method n1 4 Remove Parameter n0 4 Remove n2 Parameter 7 Extract Method 8 Extract Method  Our technique is effective − It can correctly detect impure refactorings which were actually performed − Prioritizing the candidates reduces # of applications of refactoring operations 18
  • 19. Conclusion  Summary − Detecting refactorings by a graph search, based on heuristics with structural differences between two programs − Our technique can detect impure refactorings  Future Work − Tool integration − Evaluation: larger-scale case study 19