Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University How to extract.

Slides:



Advertisements
Similar presentations
Unification and Refactoring of Clones Giri Panamoottil Krishnan and Nikolaos Tsantalis Department of Computer Science & Software Engineering Clone images.
Advertisements

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Identifying Source.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Evolutional Analysis.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
Tracy Hall, Brunel University David Bowes, University of Hertfordshire Andrew Kerr, University of Hertfordshire.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction of.
Improving the Unification of Software Clones Using Tree & Graph Matching Algorithms Giri Panamoottil Krishnan Supervisor: Dr. Nikolaos Tsantalis
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extracting Code.
A Tool Support to Merge Similar Methods with a Cohesion Metric COB ○ Masakazu Ioka 1, Norihiro Yoshida 2, Tomoo Masai 1,Yoshiki Higo 1, Katsuro Inoue 1.
Program Slicing for Refactoring Advanced SW Tools Seminar Jan 2005Yossi Peery.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A Prototype of.
Refactoring Support Tool: Cancer Yoshiki Higo Osaka University.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Industrial Application.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University ICSE 2003 Java.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Finding Similar.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A lightweight.
2006/09/19AOAsia 21 Towards Locating a Functional Concern Based on a Program Slicing Technique Takashi Ishio 1,2, Ryusuke Niitani 2 and Katsuro Inoue 2.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University What Kinds of.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A Criterion for.
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University DCCFinder: A Very- Large Scale Code Clone Analysis.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A clone detection approach for a collection of similar.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University What Do Practitioners.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 ARIES: Refactoring.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A Multi-Objective.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University Analysis and Implementation Method of Program to Detect Inappropriate.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Method to Detect License Inconsistencies for Large-
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Code-Clone Analysis.
2002/12/11PROFES20021 On software maintenance process improvement based on code clone analysis Yoshiki Higo* , Yasushi Ueda* , Toshihiro Kamiya** , Shinji.
Reishi Yokomori Nanzan University, Japan Harvey Siy University of Nebraska at Omaha, USA Norihiro Yoshida Nara Institute of Science and Technology, Japan.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Detection and evolution analysis of code clones for.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Design and Implementation.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Applying Clone.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Inoue Laboratory Eunjong Choi 1 Investigating Clone.
Debug Concern Navigator Masaru Shiozuka(Kyushu Institute of Technology, Japan) Naoyasu Ubayashi(Kyushu University, Japan) Yasutaka Kamei(Kyushu University,
Mining Logical Clones in Software: Revealing High-Level Business & Programming Rules Wenyi Qian 1, Xin Peng 1, Zhenchang Xing 2, Stan Jarzabek 3, Wenyun.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Development of.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Retrieving Similar Code Fragments based on Identifier.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 1 Towards an Assessment of the Quality of Refactoring.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 1 Towards an Investigation of Opportunities for Refactoring.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Finding Code Clones.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Cage: A Keyword.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University A Slicing Method for Object-Oriented Programs Using Lightweight.
Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM.
Experience of Finding Inconsistently-Changed Bugs in Code Clones of Mobile Software Katsuro Inoue†, Yoshiki Higo†, Norihiro Yoshida†, Eunjong Choi†, Shinji.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Classification.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction of.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Extracting Sequence.
What kind of and how clones are refactored? A case study of three OSS projects WRT2012 June 1, Eunjong Choi†, Norihiro Yoshida‡, Katsuro Inoue†
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 コードクローン解析に基づくリファクタリング支援.
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Towards a Collection of Refactoring Patterns Based.
Recommending Adaptive Changes for Framework Evolution Barthélémy Dagenais and Martin P. Robillard ICSE08 Dec 4 th, 2008 Presented by EJ Park.
1 Gemini: Code Clone Analysis Tool †Graduate School of Engineering Science, Osaka Univ., Japan ‡ Graduate School of Information Science and Technology,
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Aries: Refactoring.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Detection of License Inconsistencies in Free and.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Estimating Code Size After a Complete Code-Clone Merge Buford Edwards III, Yuhao Wu, Makoto Matsushita, Katsuro Inoue 1 Graduate School of Information.
Naoya Ujihara1, Ali Ouni2, Takashi Ishio1, Katsuro Inoue1
Do Developers Focus on Severe Code Smells?
Yuta Nakamura1, Eunjong Choi1, Norihiro Yoshida2,
○Yuichi Semura1, Norihiro Yoshida2, Eunjong Choi3, Katsuro Inoue1
: Clone Refactoring Davood Mazinanian Nikolaos Tsantalis Raphael Stein
Refactoring Support Tool: Cancer
On Refactoring Support Based on Code Clone Dependency Relation
Kazuki Yokoi1 Eunjong Choi2 Norihiro Yoshida3 Katsuro Inoue1
Precise Condition Synthesis for Program Repair
Dotri Quoc†, Kazuo Kobori†, Norihiro Yoshida
Presentation transcript:

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University How to extract differences from similar programs? : A cohesion metric approach ○Akira Goto 1, Norihiro Yoshida 2, Masakazu Ioka 1, Eunjong Choi 1, Katsuro Inoue 1 IWSC Osaka University, Japan 2 Nara Institute of Science and Technology, Japan

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Addressing code clone problem 1 Remove ManageIgnore Code Clone

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Form Template Method 2 [1] M. Fowler. Refactoring: Improving the Design of Existing Code. Addison Wesley, Refactoring pattern based on Template Method pattern [1]. Difference Extraction Class A Extracted Method A Similar Method A Class B Extracted Method B Similar Method B Super Class Merged Method Pull Up Common Part 1 2

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Difference Extraction (1/2) 3 public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Ellipse2D.Double(0, 0, width, height)); } ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Difference Extraction (2/2) 4 public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); newMethod(graphics); } public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); newMethod(graphics); } ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ public void newMethod(Graphics2D graphics) { graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width,height, start, stop, type)); } public void newMethod(Graphics2D graphics) { graphics.draw(new Ellipse2D.Double(0, 0, width, height)); }

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction based on semantics (1/2) 5 public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Ellipse2D.Double(0, 0, width, height)); } ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ Semantic Difference

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Extraction based on semantics (2/2) 6 public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { drawOutline(graphics); } public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { drawOutline(graphics); } ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ public void drawOutline(Graphics2D graphics) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } public void drawOutline(Graphics2D graphics) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Ellipse2D.Double(0, 0, width, height)); } The extracted methods have a single functionality

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Research Goal Suggest semantic differences for merging similar methods to developers 7

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Overview of Proposed Approach Propose the concept of EM candidate –It means Extract Method candidate for merging similar methods Detect all of EM candidates and rank them by slice-based cohesion metrics 8

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University EM candidate 9 After each code fragment is extracted, the similar methods are syntactically identical. Cond. 4 For all differences, the code fragment exists that include it. Cond. 3 Any two code fragments are not overlapped each other. Cond. 2 All of code fragments satisfy preconditions for extract method. Cond. 1 Set of code fragments satisfies the following conditions.

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Examples of EM candidate 10 public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width, height, start, stop, type)); } public PlanarImage executeDrawOperation() { if (!stroke.equals(”transparent”)) { BasicStroke bStroke = new BasicStroke(stroke_width); graphics.setColor(ColorMapper.getColorByName(stroke)); graphics.setStroke(bStroke); graphics.draw(new Ellipse2D.Double(0, 0, width, height)); } ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ EM candidates can be extacted for merging similar methods

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Steps of Proposed Approach 11 Step1 Step2 Step3 Step4 Input : Similar methods ASTs of the similar methods Syntactic differences EM candidates Output : Ranking of EM candidates

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step 1 : Generate ASTs 12 Step1 Step2 Step3 Step4 Input : Similar methods ASTs of the similar methods Syntactic differences EM candidates Output : Ranking of EM candidates Generate ASTs of given similar methods using Eclipse JDT

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step 2 : Comparing ASTs 13 Step1 Step2 Step3 Step4 Input : Similar methods ASTs of the similar methods Syntactic differences EM candidates Output : Ranking of EM candidates Identify syntactic differences based on ASTs comparison

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step2 : Comparing ASTs Compare nodes depth-first order from root node Find nearest parent node represents a statement 14 Different nodes Different subtrees corresponds different statements

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step 3 : Detecting EM Candidates 15 Step1 Step2 Step3 Step4 Input : Similar methods ASTs of the similar methods Syntactic differences EM candidates Output : Ranking of EM candidates Detect EM candidates using ASTs

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step 3-1 : Expand area of EM candidate Step 3-2 : Check preconditions for Extract Method 16 public void similarMethodB(){ finalBuffer.position(0); transform(finalBuffer.array(),0); finalBuffer.position(0); } finalBuffer.putLong(length << 3); finalBuffer.position(0); transform(finalBuffer.array(),0); } public void similarMethodA(){ finalBuffer.position(0); transform(finalBuffer); finalBuffer.position(0); } finalBuffer.putLong(length << 3); finalBuffer.position(0); transform(finalBuffer); } Step 3-2 : Checking PreconditionsStep 3-1: Expansion ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ Step 3 : Detecting EM Candidates

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Step 4 : Ranking EM Candidates 17 Step1 Step2 Step3 Step4 Input : Similar methods ASTs of the similar methods Syntactic differences EM candidates Output : Ranking of EM candidates Rank EM candidates based on slice- based cohesion metrics

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Slice-Based Cohesion Metrics (1/2) Slice-based cohesion metrics [2]. –Tightness, Coverage, Overlap We modify these metrics for a method that has no output variable. –Argument variables can be slicing criteria. –FTightness, FCoverage, FOverlap 18 [2] Weiser: Program slicing, Proc. of ICSE1981

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Intersection of all of the slices Slice-Based Cohesion Metrics (2/2) 19 int permutation(int a, int b) { int i; int result = 1; for (i = 0; i < b; i++) { result = result * a; a = a – 1; } return result; } |||||| SL a |||||||| SL b |||||||||||| SL result |||||| SL int Backward slice based on output variable result FTightness = FCoverage = FOverlap = Forward slices based on argument variables a and b

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University EM candidates are ranked in descending order of each metric. –3 rankings are generated by each metric FTightness FCoverageFOverlap ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ Step 4 : Ranking EM Candidates

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposed Tool : MeDiCo 21

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Case Study 22 Target Similar Methods MeDiCo FTightness FCoverage FOverlap ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ ・・・・・・ We perform refacotring using EM candidates ranked top 10 in cohesion based ranking Apply Output

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Target Similar Methods Software : Apache Ant Package : org.apache.tools.ant.types.optional.image Class : Arc and Ellipse Method : executeDrawOperation Behavior preservation is confirmed by JUnit test suites in the Apache Ant. –Number of test cases :

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Calculate the slice-based cohesion metrics before and after refactoring. 24 Evolution of Cohesion Metrics (1/2) Extracted differences Merged method Calculate increase rate of silice based metrics Target Similar Methods

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Increase rate of FTightnessFCoverageFOverlap avemaxminavemaxminavemaxmin Ranked by FTightness22%54%5%22%54%5%0% FCoverage17%25%5%17%25%5%0% FOverlap22%54%5%22%54%5%0% Evolution of Cohesion Metrics (2/2) 25 Increase rate of cohesion metrics –Both FTightness and FCoverage are always increased after refactoring. –FOverlap metric is unchanged from 1.0.

Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Conclusion & Future Work Conclusion –Propose the approach to support merging similar methods using slice-based cohesion metrics. –Confirm the usefulness of the FTightness and FOverlap metrics in the case study. Future work –Conduct larger case studies and ask developers to evaluate detected EM candidates by our approach 26