SlideShare a Scribd company logo
UNDERSTANDING SOURCE CODE DIFFERENCES
   BY SEPARATING REFACTORING EFFECTS	

*Sirinut Thangthumachit, Shinpei Hayashi, Motoshi Saeki
           Tokyo Institute of Technology, Japan
2	




    Motivation 	
     •  Source code differences
        •  Comparing and reading the differences of old and new
           versions of source code
     •  Refactoring complicates differences[1,2]
       •  Refactoring: the technique to restructuring source code
         that will not change program’s behavior
          •  makes large amount of differences
          •  shows same differences multiple times
          •  hides other changes’ differences

[1] K. Prete et al, “Template-based reconstruction of complex refactorings” ,
ICSM2010.
[2] Weißgerber et al, “Identifying refactoring from source-code changes” ,
ASE2006.
3	




Source Code Differences	


 public ThreadPoolRxTaskPool (int … 	




RED: deleted code	
    BLUE: added code
Example	
                                                              4	


   public ThreadPool (int maxThreads, int minThreads,
 ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
 throws Exception {
     // fill up the pool with worker threads
     this.maxThreads = maxThreadsmaxTasks = maxTasks;
     this.minThreads = minThreadsminTasks = minTasks;
     this.creator = creator;
     //for (int i = 0; i < minThreads; i++) {
     for (int i = 0; i < maxThreads; i++) { //temporary fix for thread
 hand off problem
       WorkerThread thread = creator.getWorkerThread();
       setupThread(thread);
       idle.add (thread);
     }
   }

   protected void setupThread(WorkerThread
 threadconfigureTask(AbstractRxTask task) {
     synchronized (threadtask) {
       thread.setPooltask.setTaskPool(this);
       thread.setName(thread//            task.setName(task.getClass
 ().getName() + "[" + inc() + "]");
       thread//            task.setDaemon(true);
       thread//            task.setPriority(Thread.MAX_PRIORITY);
       thread//            task.start();
       try {thread.wait(500); }catch ( InterruptedException x ) {}
     }
   }
                                                        Apache Tomcat 6.0.4 – 6.0.5
Example	
                                        5	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }
Example	
                                        6	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }



   Delete ‘for-loop’
Example	
                                              7	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }
                            Class ‘ThreadPool’ → ‘RxTaskPool’



   Delete ‘for-loop’
Example	
                                              8	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }
                            Class ‘ThreadPool’ → ‘RxTaskPool’
                          Parameter ‘maxThreads’ → ‘maxTasks’


   Delete ‘for-loop’
Example	
                                                9	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }
                            Class ‘ThreadPool’ → ‘RxTaskPool’
                          Parameter ‘maxThreads’ → ‘maxTasks’
                                   4 more refactorings
   Delete ‘for-loop’
Example	
                                         10	


  public ThreadPool (int maxThreads, int minThreads,
ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr
eator creator) throws Exception {
    // fill up the pool with worker threads
    this.maxThreads = maxThreadsmaxTasks = maxTasks;
    this.minThreads = minThreadsminTasks = minTasks;
    this.creator = creator;
    //for (int i = 0; i < minThreads; i++) {
    for (int i = 0; i < maxThreads; i++) { //temporary
fix for thread hand off problem
      WorkerThread thread = creator.getWorkerThread();
      setupThread(thread);
      idle.add (thread);
    }
  }



   Delete ‘for-loop’ 	
            Refactorings
Example	
                                                              11	


   public ThreadPool (int maxThreads, int minThreads,
 ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
 throws Exception {
     // fill up the pool with worker threads
     this.maxThreads = maxThreadsmaxTasks = maxTasks;
     this.minThreads = minThreadsminTasks = minTasks;
     this.creator = creator;
     //for (int i = 0; i < minThreads; i++) {
     for (int i = 0; i < maxThreads; i++) { //temporary fix for thread
 hand off problem
       WorkerThread thread = creator.getWorkerThread();
       setupThread(thread);
       idle.add (thread);
     }
   }

   protected void setupThread(WorkerThread
 threadconfigureTask(AbstractRxTask task) {
     synchronized (threadtask) {
       thread.setPooltask.setTaskPool(this);
       thread.setName(thread//            task.setName(task.getClass
 ().getName() + "[" + inc() + "]");
       thread//            task.setDaemon(true);
       thread//            task.setPriority(Thread.MAX_PRIORITY);
       thread//            task.start();
       try {thread.wait(500); }catch ( InterruptedException x ) {}
     }
   }
                                                        Apache Tomcat 6.0.4 – 6.0.5
Example	
                                         12	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }
Example	
                                         13	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }




     Comment Out
Example	
                                              14	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }


                          Method ‘setupThread’ → ‘configureTask’



     Comment Out
Example	
                                              15	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }


                          Method ‘setupThread’ → ‘configureTask’
                               Parameter ‘thread’ → ‘task’


     Comment Out
Example	
                                                 16	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }


                          Method ‘setupThread’ → ‘configureTask’
                               Parameter ‘thread’ → ‘task’
                                    2 more refactorings
     Comment Out
Example	
                                         17	




  protected void setupThread(WorkerThread threadconfigure
Task(AbstractRxTask task) {
    synchronized (threadtask) {
   thread.setPooltask.setTaskPool(this);
       thread.setName(thread//       task.setName(task.
getClass().getName() + "[" + inc() + "]");
      thread//       task.setDaemon(true);
      thread//       task.setPriority(Thread.MAX_PRIORITY);
   thread//       task.start();
   try {thread.wait(500); }catch ( InterruptedException x )
    }
  }




     Comment Out	
                 Refactorings
18	




 Basic Ideas	
•  Developer knows refactoring well
   •  ‘ThreadPool’ was renamed to ‘RxTaskPool’
•  → It is no need to read refactorings in source code
 differences
 •  ThreadPoolRxTaskPool


•  → Extract & Eliminate Refactorings
 •  Source code differences without refactoring
•  → Show refactoring information to user
Separating Refactorings	
                                                  19	



      public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
   throws Exception {	
          // fill up the pool with worker threads	
          this.maxTasks = maxTasks;	
          this.minTasks = minTasks;	
          this.creator = creator;	
          //for (int i = 0; i < minThreads; i++) {	
          for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand
   off problem	
              AbstractRxTask thread = creator.createRxTask();	
              configureTask(thread);	
              idle.add (thread);	
          }	
      }	
      	
      protected void configureTask(AbstractRxTask task) {	
          synchronized (task) {	
                   task.setTaskPool(this);	
   //                 task.setName(task.getClass().getName() + "[" + inc() + "]");	
   //                 task.setDaemon(true);	
   //                 task.setPriority(Thread.MAX_PRIORITY);	
   //                 task.start();	
              try {Thread.wait(500); }catch ( InterruptedException x ) {}	
          }	
      }	
                                               ‘ThreadPool’ → ‘RxTaskPool’
                                                      ‘setupThread’ → ‘configureTask’
                                                      and 8 more.
Separating Refactorings	
                                                    20	

                                              public ThreadPool (int maxThreads, int minThre
      public RxTaskPool (int maxTasks, ThreadCreatorRxTaskPool (int maxTasks, int minTa
                                           int minTasks, TaskCreator creator)
   throws Exception {	
                   throws Exception {
          // fill up the pool with worker threads	
 up the pool with worker threads
                                                // fill
          this.maxTasks = maxTasks;	
           this.maxThreads = maxThreadsmaxTasks = maxTa
          this.minTasks = minTasks;	
           this.minThreads = minThreadsminTasks = minTa
          this.creator = creator;	
             this.creator = creator;
          //for (int i = 0; i < minThreads; i++) {	
                                                //for (int i = 0; i < minThreads; i++) {
          for (int i = 0; i < maxTasks; i++) for//temporary fix <for thread hand
                                                 { (int i = 0; i     maxThreads; i++) { //tem
   off problem	
                          hand off problem
              AbstractRxTask thread = creator.createRxTask();	
                                                  WorkerThread thread = creator.getWorkerThr
              configureTask(thread);	
            setupThread(thread);
              idle.add (thread);	
                idle.add (thread);
          }	
                                   }
      }	
                                     }
      	
      protected void configureTask(AbstractRxTask task) setupThread(WorkerThread
                                              protected void {	
          synchronized (task) {	
         threadconfigureTask(AbstractRxTask task) {
                   task.setTaskPool(this);	
    synchronized (threadtask) {
   //                 task.setName(task.getClass().getName() + "[" + inc() + "]");	
                                                  thread.setPooltask.setTaskPool(this);
   //                 task.setDaemon(true);	
     thread.setName(thread//             task.se
   //                 task.setPriority(Thread.MAX_PRIORITY);	
 + inc() + "]");
                                          ().getName() + "["
   //                 task.start();	
             thread//             task.setDaemon(true);
              try {Thread.wait(500); }catch ( InterruptedException xtask.setPriority(Threa
                                                  thread//              ) {}	
          }	
                                     thread//             task.start();
      }	
                                         try {thread.wait(500); }catch ( Interrupte
                                                           ‘ThreadPool’ → ‘RxTaskPool’
                                                }
                Without Refactorings 	
       } With Refactorings 	
                                                           ‘setupThread’ → ‘configureTask’
                                                       and 8 more.
Separating Refactorings	
                                                  21	



      public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
   throws Exception {	
          // fill up the pool with worker threads	
          this.maxTasks = maxTasks;	
          this.minTasks = minTasks;	
          this.creator = creator;	
          //for (int i = 0; i < minThreads; i++) {	
          for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand
   off problem	
              AbstractRxTask thread = creator.createRxTask();	
              configureTask(thread);	
              idle.add (thread);	
          }	
      }	
      	
      protected void configureTask(AbstractRxTask task) {	
                                                                Delete 'for-loop' 	
          synchronized (task) {	
                   task.setTaskPool(this);	
   //                 task.setName(task.getClass().getName() + "[" + inc() + "]");	
   //                 task.setDaemon(true);	
   //                 task.setPriority(Thread.MAX_PRIORITY);	
   //                 task.start();	
              try {Thread.wait(500); }catch ( InterruptedException x ) {}	
          }	
      }	
                                               ‘ThreadPool’ → ‘RxTaskPool’
                                                      ‘setupThread’ → ‘configureTask’
                                                      and 8 more.
Separating Refactorings	
                                                  22	



      public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
   throws Exception {	
          // fill up the pool with worker threads	
          this.maxTasks = maxTasks;	
          this.minTasks = minTasks;	
          this.creator = creator;	
          //for (int i = 0; i < minThreads; i++) {	
          for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand
   off problem	
              AbstractRxTask thread = creator.createRxTask();	
              configureTask(thread);	
              idle.add (thread);	
          }	
      }	
      	
      protected void configureTask(AbstractRxTask task) {	
                                                                Delete 'for-loop' 	
          synchronized (task) {	
                   task.setTaskPool(this);	
                     Comment out	
   //                 task.setName(task.getClass().getName() + "[" + inc() + "]");	
   //                 task.setDaemon(true);	
   //                 task.setPriority(Thread.MAX_PRIORITY);	
   //                 task.start();	
              try {Thread.wait(500); }catch ( InterruptedException x ) {}	
          }	
      }	
                                               ‘ThreadPool’ → ‘RxTaskPool’
                                                      ‘setupThread’ → ‘configureTask’
                                                      and 8 more.
Separating Refactorings	
                                                  23	



      public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator)
   throws Exception {	
          // fill up the pool with worker threads	
          this.maxTasks = maxTasks;	
          this.minTasks = minTasks;	
          this.creator = creator;	
          //for (int i = 0; i < minThreads; i++) {	
          for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand
   off problem	
              AbstractRxTask thread = creator.createRxTask();	
              configureTask(thread);	
              idle.add (thread);	
          }	
      }	
      	
      protected void configureTask(AbstractRxTask task) {	
                                                                Delete 'for-loop' 	
          synchronized (task) {	
                   task.setTaskPool(this);	
                    Comment out	
   //                 task.setName(task.getClass().getName() + "[" + inc() + "]");	
   //                 task.setDaemon(true);	
                  Delete 'try&catch'	
   //                 task.setPriority(Thread.MAX_PRIORITY);	
   //                 task.start();	
              try {Thread.wait(500); }catch ( InterruptedException x ) {}	
          }	
      }	
                                               ‘ThreadPool’ → ‘RxTaskPool’
                                                      ‘setupThread’ → ‘configureTask’
                                                      and 8 more.
24	

                         Old	
   Old version of source code
                                 New version of source code
Approach	
                         New	

                                 Source code differences
                                 refactoring	




   Old	
                               New	




Old	
        Modified	
                         New
25	




Overview of the proposed technique	

New Ver.	


              Separating          Comparing

Old Ver.	
   Refactorings	
      Source Code	

  Inputs	
                                 Source Code

                                  Differences

                              without Refactoring	

                                 Ordered List

                                of Refactorings	
                                    Outputs
26	




Overview of the proposed technique	

               New Ver.	
 Input 2	



               Extracting
Old Ver.	
              Refactorings	
 Input 1	
             Ordered List of
              Refactorings	
           Applying "       Modified

                                      Refactorings	
      Ver.	
                                                         Output 2	

                 Output 1
27	




    Overview of the proposed technique	

New	




                                          Method"                  Comparing

 Old	
     Package	
   File	
   Class	
              Local	
      Source Code	
                                           Field	
Inputs	



                                                                  Source Code

                                                                   Differences

                                                               without Refactoring	


                                                                  Ordered List

                                                                 of Refactorings	
                                                                     Outputs
Supporting tool	
  •  Refactoring Extraction
     •  Automatical extraction
     •  External Input
  •  Refactoring Application
     •  Automatically apply by using Eclipse Refactoring
         Browser

                           Extraction	
                Application	
               packages, files, classes, interfaces,
Rename	
                                                all elements	
                       enums, methods	
Move	
                    files, methods	
             files, methods	
                                                                      28	
Extract	
                        -	
                     methods
Evaluations	
•  Application on OSS
   •  Can extracted refactorings be applied?
   •  Can separating refactorings reduce the amount of source
      code differences?


•  Human Subject Study
   •  With approach, can subjects understand more changes in
      the same limited time?
   •  Does the approach satisfy subjects?

                                                          29
Evaluation 1 (Application on OSS)	
•  Target projects
   •  OW2 Carol 1.0.1-1.8.5 (30 pairs)
•  Result
   •  Tool found refactorings in 5 pairs
    •  1.0.1–1.3.0, 1.4.0–1.4.2, 1.5.2–1.5.3, 1.5.6–1.5.7, 1.5.8–1.6.

  •  Refactorings application

                                          Found	
            Successfully applied	
    Detected Refactorings                   21	
                        18	
    False                                    5	
                        2	
    True	
                                  16	
                        16	
                                                                                  30	
  •  → All real refactorings were applied successfully
Evaluation 1	
•  The amount of source code differences
                                   Changed lines	
  WO: without approach             18,721 (100%)	
  A: with approach	
              14,624 (78.12%)	
  WO - A	
                         4,097 (21.88%)	

 → Approach reduced more than 21%

•  Can extracted refactorings be applied?
   •  → Yes
•  Can separating refactorings reduce the amount of source
 code differences?
                                                       31	
  •  → Yes
Evaluation 2 (Human Subject)	
•  Procedure
   •  Let subjects read the source code differences with and
      without our approach.
   •  Ask them to answer what was changed between the
      versions
   •  Evaluate by time and changes found
•  Target Projects
  •  OW2 Carol 1.5.6-1.5.7
  •  Apache Tomcat 6.0.4-6.0.5

                                                               32
33	




 Evaluation 2	
•  Subjects
  Subjects	
          A	
                  B	
                C	
                D	
    Carol	
       Approach	
      w/o Approach	
           Approach	
      w/o approach
   Tomcat	
     w/o Approach	
      Approach	
        w/o Approach	
         Approach	


•  Result
                               Changes             Time              Efficiency
                                found	
          (minute)	
     (changes found/ time)	
              w/o Approach	
     28.3	
           112.75	
              0.25 (100%)	
 average	
               Approach	
        39.25	
           120	
                0.33 (132%)	

•  → Approach made 32% higher efficiency
34	




 Evaluation 2	
•  Questionnaires
   •  All subjects agreed that our approach is useful
    •  Especially, renaming class.




  •  With approach, can subjects understand more changes in
   the same limited time?
    •  → Yes
  •  Does the approach satisfy subjects?
     •  → Yes
Conclusion	
•  Understanding source code differences by
 separating refactorings effects
 •  Separating refactorings
 •  Implemented supporting tool
    •  Rename + Move refactorings
 •  Evaluations
    •  Approach is applicable to OSS
    •  Separating refactorings helps understanding differences

•  Future Works
   •  Better tool
    •  Support more refactoring types                            35

More Related Content

What's hot (20)

PDF
Fun Teaching MongoDB New Tricks
MongoDB
 
PDF
Java 7 JUG Summer Camp
julien.ponge
 
PDF
Spock and Geb in Action
Christian Baranowski
 
PDF
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
PDF
Real Time Web with Node
Tim Caswell
 
PDF
Node Powered Mobile
Tim Caswell
 
PPT
Java util concurrent
Roger Xia
 
PDF
Concurrency Concepts in Java
Doug Hawkins
 
PDF
The Ring programming language version 1.5.2 book - Part 76 of 181
Mahmoud Samir Fayed
 
PPTX
JPoint 2016 - Валеев Тагир - Странности Stream API
tvaleev
 
PDF
groovy databases
Paul King
 
PDF
Java 7 LavaJUG
julien.ponge
 
PDF
Java Performance Puzzlers
Doug Hawkins
 
PDF
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
PPTX
Nantes Jug - Java 7
Sébastien Prunier
 
PDF
The Ring programming language version 1.8 book - Part 54 of 202
Mahmoud Samir Fayed
 
PDF
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
Simon Su
 
KEY
Do more than one thing at the same time, the Python way
Jaime Buelta
 
PDF
#JavaFX.forReal() - ElsassJUG
Thierry Wasylczenko
 
PDF
Programming with ZooKeeper - A basic tutorial
Jeff Smith
 
Fun Teaching MongoDB New Tricks
MongoDB
 
Java 7 JUG Summer Camp
julien.ponge
 
Spock and Geb in Action
Christian Baranowski
 
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
Real Time Web with Node
Tim Caswell
 
Node Powered Mobile
Tim Caswell
 
Java util concurrent
Roger Xia
 
Concurrency Concepts in Java
Doug Hawkins
 
The Ring programming language version 1.5.2 book - Part 76 of 181
Mahmoud Samir Fayed
 
JPoint 2016 - Валеев Тагир - Странности Stream API
tvaleev
 
groovy databases
Paul King
 
Java 7 LavaJUG
julien.ponge
 
Java Performance Puzzlers
Doug Hawkins
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
Nantes Jug - Java 7
Sébastien Prunier
 
The Ring programming language version 1.8 book - Part 54 of 202
Mahmoud Samir Fayed
 
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
Simon Su
 
Do more than one thing at the same time, the Python way
Jaime Buelta
 
#JavaFX.forReal() - ElsassJUG
Thierry Wasylczenko
 
Programming with ZooKeeper - A basic tutorial
Jeff Smith
 

Viewers also liked (20)

PDF
Toward Understanding How Developers Recognize Features in Source Code from De...
Institute of Science Tokyo
 
PDF
Historef: A Tool for Edit History Refactoring
Institute of Science Tokyo
 
PDF
Terminology Matching of Requirements Specification Documents and Regulations ...
Institute of Science Tokyo
 
PDF
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
Institute of Science Tokyo
 
PDF
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Institute of Science Tokyo
 
PDF
Incremental Feature Location and Identification in Source Code
Hiroshi Kazato
 
PDF
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Institute of Science Tokyo
 
PDF
Detecting Occurrences of Refactoring with Heuristic Search
Institute of Science Tokyo
 
PDF
Toward Structured Location of Features
Hiroshi Kazato
 
PDF
Refactoring Edit History of Source Code
Institute of Science Tokyo
 
PDF
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Institute of Science Tokyo
 
PDF
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Institute of Science Tokyo
 
PDF
Sentence-to-Code Traceability Recovery with Domain Ontologies
Institute of Science Tokyo
 
PDF
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Institute of Science Tokyo
 
PDF
Recording Finer-Grained Software Evolution with IDE: An Annotation-Based Appr...
Institute of Science Tokyo
 
PDF
iFL: An Interactive Environment for Understanding Feature Implementations
Institute of Science Tokyo
 
PDF
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Institute of Science Tokyo
 
PDF
Visualizing Stakeholder Concerns with Anchored Map
Takanori Ugai
 
PDF
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Hiroshi Kazato
 
PDF
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
Takashi Kobayashi
 
Toward Understanding How Developers Recognize Features in Source Code from De...
Institute of Science Tokyo
 
Historef: A Tool for Edit History Refactoring
Institute of Science Tokyo
 
Terminology Matching of Requirements Specification Documents and Regulations ...
Institute of Science Tokyo
 
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
Institute of Science Tokyo
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Institute of Science Tokyo
 
Incremental Feature Location and Identification in Source Code
Hiroshi Kazato
 
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Institute of Science Tokyo
 
Detecting Occurrences of Refactoring with Heuristic Search
Institute of Science Tokyo
 
Toward Structured Location of Features
Hiroshi Kazato
 
Refactoring Edit History of Source Code
Institute of Science Tokyo
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Institute of Science Tokyo
 
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Institute of Science Tokyo
 
Sentence-to-Code Traceability Recovery with Domain Ontologies
Institute of Science Tokyo
 
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Institute of Science Tokyo
 
Recording Finer-Grained Software Evolution with IDE: An Annotation-Based Appr...
Institute of Science Tokyo
 
iFL: An Interactive Environment for Understanding Feature Implementations
Institute of Science Tokyo
 
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Institute of Science Tokyo
 
Visualizing Stakeholder Concerns with Anchored Map
Takanori Ugai
 
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Hiroshi Kazato
 
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
Takashi Kobayashi
 
Ad

Similar to Understanding Source Code Differences by Separating Refactoring Effects (20)

PPTX
Multi Threading
Ferdin Joe John Joseph PhD
 
ODP
Java 7 new features
Aliaksandr Kazlou
 
PPTX
Slide 7 Thread-1.pptx
ajmalhamidi1380
 
PPTX
Async task, threads, pools, and executors oh my!
Stacy Devino
 
PPTX
Java concurrency - Thread pools
maksym220889
 
PPTX
Java Multithreading - how to create threads
ManishKumar475693
 
PDF
Java concurrency
Abhijit Gaikwad
 
PDF
Core Java Programming Language (JSE) : Chapter XII - Threads
WebStackAcademy
 
PDF
Java Multithreading Using Executors Framework
Arun Mehra
 
PPT
Java multi threading
Raja Sekhar
 
PPTX
Tools and Techniques for Understanding Threading Behavior in Android*
Intel® Software
 
PPTX
Java concurrency
Hithem Ahmed
 
PPTX
Multithreading.pptx
ssuserfcae42
 
PDF
Tools and Techniques for Understanding Threading Behavior in Android
Intel® Software
 
PPT
Parallel programming
Swain Loda
 
PPTX
concurrency_c#_public
Paul Churchward
 
PDF
Concurrency and Thread-Safe Data Processing in Background Tasks
WO Community
 
PPTX
.NET Multithreading/Multitasking
Sasha Kravchuk
 
PPTX
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Sachintha Gunasena
 
ODP
Concurrent Programming in Java
Ruben Inoto Soto
 
Java 7 new features
Aliaksandr Kazlou
 
Slide 7 Thread-1.pptx
ajmalhamidi1380
 
Async task, threads, pools, and executors oh my!
Stacy Devino
 
Java concurrency - Thread pools
maksym220889
 
Java Multithreading - how to create threads
ManishKumar475693
 
Java concurrency
Abhijit Gaikwad
 
Core Java Programming Language (JSE) : Chapter XII - Threads
WebStackAcademy
 
Java Multithreading Using Executors Framework
Arun Mehra
 
Java multi threading
Raja Sekhar
 
Tools and Techniques for Understanding Threading Behavior in Android*
Intel® Software
 
Java concurrency
Hithem Ahmed
 
Multithreading.pptx
ssuserfcae42
 
Tools and Techniques for Understanding Threading Behavior in Android
Intel® Software
 
Parallel programming
Swain Loda
 
concurrency_c#_public
Paul Churchward
 
Concurrency and Thread-Safe Data Processing in Background Tasks
WO Community
 
.NET Multithreading/Multitasking
Sasha Kravchuk
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Sachintha Gunasena
 
Concurrent Programming in Java
Ruben Inoto Soto
 
Ad

More from Institute of Science Tokyo (9)

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

Recently uploaded (20)

PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PPTX
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
PDF
Open Source Milvus Vector Database v 2.6
Zilliz
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PPTX
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
Open Source Milvus Vector Database v 2.6
Zilliz
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Python Conference Singapore - 19 Jun 2025
ninefyi
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Priyanka Aash
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 

Understanding Source Code Differences by Separating Refactoring Effects

  • 1. UNDERSTANDING SOURCE CODE DIFFERENCES BY SEPARATING REFACTORING EFFECTS *Sirinut Thangthumachit, Shinpei Hayashi, Motoshi Saeki Tokyo Institute of Technology, Japan
  • 2. 2 Motivation •  Source code differences •  Comparing and reading the differences of old and new versions of source code •  Refactoring complicates differences[1,2] •  Refactoring: the technique to restructuring source code that will not change program’s behavior •  makes large amount of differences •  shows same differences multiple times •  hides other changes’ differences [1] K. Prete et al, “Template-based reconstruction of complex refactorings” , ICSM2010. [2] Weißgerber et al, “Identifying refactoring from source-code changes” , ASE2006.
  • 3. 3 Source Code Differences public ThreadPoolRxTaskPool (int … RED: deleted code BLUE: added code
  • 4. Example 4 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } protected void setupThread(WorkerThread threadconfigureTask(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task.getClass ().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) {} } } Apache Tomcat 6.0.4 – 6.0.5
  • 5. Example 5 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } }
  • 6. Example 6 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } Delete ‘for-loop’
  • 7. Example 7 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } Class ‘ThreadPool’ → ‘RxTaskPool’ Delete ‘for-loop’
  • 8. Example 8 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } Class ‘ThreadPool’ → ‘RxTaskPool’ Parameter ‘maxThreads’ → ‘maxTasks’ Delete ‘for-loop’
  • 9. Example 9 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } Class ‘ThreadPool’ → ‘RxTaskPool’ Parameter ‘maxThreads’ → ‘maxTasks’ 4 more refactorings Delete ‘for-loop’
  • 10. Example 10 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCr eator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } Delete ‘for-loop’ Refactorings
  • 11. Example 11 public ThreadPool (int maxThreads, int minThreads, ThreadCreatorRxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxThreads = maxThreadsmaxTasks = maxTasks; this.minThreads = minThreadsminTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxThreads; i++) { //temporary fix for thread hand off problem WorkerThread thread = creator.getWorkerThread(); setupThread(thread); idle.add (thread); } } protected void setupThread(WorkerThread threadconfigureTask(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task.getClass ().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) {} } } Apache Tomcat 6.0.4 – 6.0.5
  • 12. Example 12 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } }
  • 13. Example 13 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } } Comment Out
  • 14. Example 14 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } } Method ‘setupThread’ → ‘configureTask’ Comment Out
  • 15. Example 15 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } } Method ‘setupThread’ → ‘configureTask’ Parameter ‘thread’ → ‘task’ Comment Out
  • 16. Example 16 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } } Method ‘setupThread’ → ‘configureTask’ Parameter ‘thread’ → ‘task’ 2 more refactorings Comment Out
  • 17. Example 17 protected void setupThread(WorkerThread threadconfigure Task(AbstractRxTask task) { synchronized (threadtask) { thread.setPooltask.setTaskPool(this); thread.setName(thread// task.setName(task. getClass().getName() + "[" + inc() + "]"); thread// task.setDaemon(true); thread// task.setPriority(Thread.MAX_PRIORITY); thread// task.start(); try {thread.wait(500); }catch ( InterruptedException x ) } } Comment Out Refactorings
  • 18. 18 Basic Ideas •  Developer knows refactoring well •  ‘ThreadPool’ was renamed to ‘RxTaskPool’ •  → It is no need to read refactorings in source code differences •  ThreadPoolRxTaskPool •  → Extract & Eliminate Refactorings •  Source code differences without refactoring •  → Show refactoring information to user
  • 19. Separating Refactorings 19 public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxTasks = maxTasks; this.minTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand off problem AbstractRxTask thread = creator.createRxTask(); configureTask(thread); idle.add (thread); } } protected void configureTask(AbstractRxTask task) { synchronized (task) { task.setTaskPool(this); // task.setName(task.getClass().getName() + "[" + inc() + "]"); // task.setDaemon(true); // task.setPriority(Thread.MAX_PRIORITY); // task.start(); try {Thread.wait(500); }catch ( InterruptedException x ) {} } } ‘ThreadPool’ → ‘RxTaskPool’ ‘setupThread’ → ‘configureTask’ and 8 more.
  • 20. Separating Refactorings 20 public ThreadPool (int maxThreads, int minThre public RxTaskPool (int maxTasks, ThreadCreatorRxTaskPool (int maxTasks, int minTa int minTasks, TaskCreator creator) throws Exception { throws Exception { // fill up the pool with worker threads up the pool with worker threads // fill this.maxTasks = maxTasks; this.maxThreads = maxThreadsmaxTasks = maxTa this.minTasks = minTasks; this.minThreads = minThreadsminTasks = minTa this.creator = creator; this.creator = creator; //for (int i = 0; i < minThreads; i++) { //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxTasks; i++) for//temporary fix <for thread hand { (int i = 0; i maxThreads; i++) { //tem off problem hand off problem AbstractRxTask thread = creator.createRxTask(); WorkerThread thread = creator.getWorkerThr configureTask(thread); setupThread(thread); idle.add (thread); idle.add (thread); } } } } protected void configureTask(AbstractRxTask task) setupThread(WorkerThread protected void { synchronized (task) { threadconfigureTask(AbstractRxTask task) { task.setTaskPool(this); synchronized (threadtask) { // task.setName(task.getClass().getName() + "[" + inc() + "]"); thread.setPooltask.setTaskPool(this); // task.setDaemon(true); thread.setName(thread// task.se // task.setPriority(Thread.MAX_PRIORITY); + inc() + "]"); ().getName() + "[" // task.start(); thread// task.setDaemon(true); try {Thread.wait(500); }catch ( InterruptedException xtask.setPriority(Threa thread// ) {} } thread// task.start(); } try {thread.wait(500); }catch ( Interrupte ‘ThreadPool’ → ‘RxTaskPool’ } Without Refactorings } With Refactorings ‘setupThread’ → ‘configureTask’ and 8 more.
  • 21. Separating Refactorings 21 public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxTasks = maxTasks; this.minTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand off problem AbstractRxTask thread = creator.createRxTask(); configureTask(thread); idle.add (thread); } } protected void configureTask(AbstractRxTask task) { Delete 'for-loop' synchronized (task) { task.setTaskPool(this); // task.setName(task.getClass().getName() + "[" + inc() + "]"); // task.setDaemon(true); // task.setPriority(Thread.MAX_PRIORITY); // task.start(); try {Thread.wait(500); }catch ( InterruptedException x ) {} } } ‘ThreadPool’ → ‘RxTaskPool’ ‘setupThread’ → ‘configureTask’ and 8 more.
  • 22. Separating Refactorings 22 public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxTasks = maxTasks; this.minTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand off problem AbstractRxTask thread = creator.createRxTask(); configureTask(thread); idle.add (thread); } } protected void configureTask(AbstractRxTask task) { Delete 'for-loop' synchronized (task) { task.setTaskPool(this); Comment out // task.setName(task.getClass().getName() + "[" + inc() + "]"); // task.setDaemon(true); // task.setPriority(Thread.MAX_PRIORITY); // task.start(); try {Thread.wait(500); }catch ( InterruptedException x ) {} } } ‘ThreadPool’ → ‘RxTaskPool’ ‘setupThread’ → ‘configureTask’ and 8 more.
  • 23. Separating Refactorings 23 public RxTaskPool (int maxTasks, int minTasks, TaskCreator creator) throws Exception { // fill up the pool with worker threads this.maxTasks = maxTasks; this.minTasks = minTasks; this.creator = creator; //for (int i = 0; i < minThreads; i++) { for (int i = 0; i < maxTasks; i++) { //temporary fix for thread hand off problem AbstractRxTask thread = creator.createRxTask(); configureTask(thread); idle.add (thread); } } protected void configureTask(AbstractRxTask task) { Delete 'for-loop' synchronized (task) { task.setTaskPool(this); Comment out // task.setName(task.getClass().getName() + "[" + inc() + "]"); // task.setDaemon(true); Delete 'try&catch' // task.setPriority(Thread.MAX_PRIORITY); // task.start(); try {Thread.wait(500); }catch ( InterruptedException x ) {} } } ‘ThreadPool’ → ‘RxTaskPool’ ‘setupThread’ → ‘configureTask’ and 8 more.
  • 24. 24 Old Old version of source code New version of source code Approach New Source code differences refactoring Old New Old Modified New
  • 25. 25 Overview of the proposed technique New Ver. Separating Comparing
 Old Ver. Refactorings Source Code Inputs Source Code
 Differences
 without Refactoring Ordered List
 of Refactorings Outputs
  • 26. 26 Overview of the proposed technique New Ver. Input 2 Extracting Old Ver. Refactorings Input 1 Ordered List of Refactorings Applying " Modified
 Refactorings Ver. Output 2 Output 1
  • 27. 27 Overview of the proposed technique New Method" Comparing
 Old Package File Class Local Source Code Field Inputs Source Code
 Differences
 without Refactoring Ordered List
 of Refactorings Outputs
  • 28. Supporting tool •  Refactoring Extraction •  Automatical extraction •  External Input •  Refactoring Application •  Automatically apply by using Eclipse Refactoring Browser Extraction Application packages, files, classes, interfaces, Rename all elements enums, methods Move files, methods files, methods 28 Extract - methods
  • 29. Evaluations •  Application on OSS •  Can extracted refactorings be applied? •  Can separating refactorings reduce the amount of source code differences? •  Human Subject Study •  With approach, can subjects understand more changes in the same limited time? •  Does the approach satisfy subjects? 29
  • 30. Evaluation 1 (Application on OSS) •  Target projects •  OW2 Carol 1.0.1-1.8.5 (30 pairs) •  Result •  Tool found refactorings in 5 pairs •  1.0.1–1.3.0, 1.4.0–1.4.2, 1.5.2–1.5.3, 1.5.6–1.5.7, 1.5.8–1.6. •  Refactorings application Found Successfully applied Detected Refactorings 21 18 False 5 2 True 16 16 30 •  → All real refactorings were applied successfully
  • 31. Evaluation 1 •  The amount of source code differences Changed lines WO: without approach 18,721 (100%) A: with approach 14,624 (78.12%) WO - A 4,097 (21.88%)  → Approach reduced more than 21% •  Can extracted refactorings be applied? •  → Yes •  Can separating refactorings reduce the amount of source code differences? 31 •  → Yes
  • 32. Evaluation 2 (Human Subject) •  Procedure •  Let subjects read the source code differences with and without our approach. •  Ask them to answer what was changed between the versions •  Evaluate by time and changes found •  Target Projects •  OW2 Carol 1.5.6-1.5.7 •  Apache Tomcat 6.0.4-6.0.5 32
  • 33. 33 Evaluation 2 •  Subjects Subjects A B C D Carol Approach w/o Approach Approach w/o approach Tomcat w/o Approach Approach w/o Approach Approach •  Result Changes Time Efficiency found (minute) (changes found/ time) w/o Approach 28.3 112.75 0.25 (100%) average Approach 39.25 120 0.33 (132%) •  → Approach made 32% higher efficiency
  • 34. 34 Evaluation 2 •  Questionnaires •  All subjects agreed that our approach is useful •  Especially, renaming class. •  With approach, can subjects understand more changes in the same limited time? •  → Yes •  Does the approach satisfy subjects? •  → Yes
  • 35. Conclusion •  Understanding source code differences by separating refactorings effects •  Separating refactorings •  Implemented supporting tool •  Rename + Move refactorings •  Evaluations •  Approach is applicable to OSS •  Separating refactorings helps understanding differences •  Future Works •  Better tool •  Support more refactoring types 35