SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘い
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.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