Create and Undo Visitors Using R3


In this assignment you will use R3 to write two refactoring scripts: (a) one that automatically retrofits a Visitor design pattern into a legacy program, and (b) one that automatically removes a Visitor pattern from a legacy program.   You will use R3 (Eclipse plug-in) and ONLY R3 refactorings in this assignment.  Using anything else gets you 0 (zero, nada, null) for this assignment.  If you vary from what is described below, you must get permission otherwise you get no credit.


Preliminaries Part 1: R3 Installation

Please follow the steps below:
  1. Install Java Runtime Environment (JRE) if it is not installed.

    JRE version (x64)

  2. Download Eclipse and unzip it.  You must use the version of Eclipse below even if you have an existing Eclipse in your machine.
http://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/oxygen1a
  1. Run Eclipse.

    Video
  1. Download R3 and then import into Eclipse as a project.

    Video

    R3.zip or R3.zipp (rename to R3.zip after downloading)

  2. Copy and paste the following codes into the body of method myMethod() in class MyClass.
///////////////////////////////////////////////////////////////////////
//
//    Write your script here
//
//Create a new class named “D”.
  RPackage pkg = RProject.getPackage("TestProject", "testPackage");
  RClassOrInterface cls = pkg.newClass("D");
//
///////////////////////////////////////////////////////////////////////
  1. Run R3 (as "Eclipse Application").

    Video

  2. Download TestProject program.  TestProject is the target program to be refactored.

    TestProject.zip

  3. Import the TestProject program into Eclipse plug-in.  Now you have two Eclipse instances (R3 and TestProject) running.

    Video

  4. Try "Preview".

    Video

  5. Execute the R3 script.

    Video


  6. Check whether a new class named "D" is created successfully.

Do NOT proceed to the next part of this assignment if you fail the test in Step 11.


Preliminaries Part 2: Initialize R3

Please follow the steps below:
  1. Read very carefully tutorials below.
  1. Delete Eclipse "runtime-EclipseApplication" directory (if it does exist):

    Video

    The location is:
  2. Run Eclipse (installed at Preliminaries Part 1).

Part 1: Make-Visitor Using R3

Please follow the steps below:
  1. Follow Preliminaries Part 2: Initialize R3

  2. Find R3 project in the Eclipse "Package Explorer".
  1. Run R3 (as "Eclipse Application").

  2. Download RefactoringCrawler program and then import into Eclipse plug-in.  RefactoringCrawler is the target program to be refactored You don’t need to understand the semantics of RefactoringCrawler.

    Watch this video on how to import an Eclipse Project.

    Download RefactoringCrawler.zip

  3. Write your R3 script that makes a Visitor pattern for method computeLikeliness(Node, Node) in class edu.uiuc.detectRefactorings.detection.FieldDetection.
  1. Execute your R3 script.  (Tip: "Preview" is useful to see if your R3 script can run.)

  2. Run regression tests on package edu.uiuc.tests to see if the refactored RefactoringCrawler works correctly. If it works, proceed to the next step. 

    Run as "JUnit Test" (not as "JUnit Plug-in Test") which executes 10 (not 15) regression tests.  
    Watch this video.  

  3. Export your RefactoringCrawler+ a PDF File containing/explaining your R3 script  named "MakeVisitorUsingR3.zip".  Watch this video.

  4. Export your RefactoringCrawler + a PDF File containing/explaining your R3 script  named "MakeVisitorUsingR3.zip".

  5. Create "MakeVisitorUsingR3.zip".

Part 2: Undo-Visitor Using R3

Please follow the steps below:
  1. Follow Preliminaries Part 2: Initialize R3

  2. Find R3 project in the Eclipse "Package Explorer".
  1. Run R3 (as "Eclipse Application").

  2. Download RefactoringCrawlerWithVisitor program and then import into Eclipse as a project.  RefactoringCrawlerWithVisitor is the target program to be refactored.  You don’t need to understand the semantics of RefactoringCrawlerWithVisitor.

    Watch this video on how to import an Eclipse Project.

    Then download  RefactoringCrawlerWithVisitor.zip
  1. Write your R3 script that undoes a Visitor pattern of class Visitor in package edu.uiuc.detectRefactorings.detection and set the original method name as "isRename".
  1. Execute your R3 script.  (Tip: "Preview" is useful to see if your R3 script can run.)

  2. Run regression tests on package edu.uiuc.tests to see if the refactored RefactoringCrawlerWithVisitor works correctly. If it works, proceed to the next step. 
     
    Run as "JUnit Test" (not as "JUnit Plug-in Test") which executes 10 (not 15) regression tests.  
    Watch this video. 
  1. Export your RefactoringCrawlerWithVisitor + a PDF File containing/explaining your R3 script  named "UndoVisitorUsingR3.zip".   Watch this video.

  2. Create "UndoVisitorUsingR3.zip".


What to Submit

All of the below in a zip file (including your R3 Eclipse Projects). The zip file must unzip into <yourName>/<YourFilesAndDirectories>.
  1. Your program needs to run correctly on Linux machines, even though you may have developed them on Macs and Windoze.  The TA will grade your program running on Linux.

  2. A short description that the Grader needs to know to run your program, other than the above. 

  3. A short writeup explaining any difficulties in using R3 for this assignment.

  4. A PDF file (in the required format) that the Grader should read to provide any information that is not obvious.  The contents of the PDF file can be minimal.

A critical part of any design is clarity and understandability.   Hence, you will be graded on the clarity of your project and its ability to work correctly.  Sloppy code, documentation, or anything that makes grading or understanding your program difficult will cost you points.  Beware, some of these "beauty" points are subjective. 

Remember: No late assignments/submissions will be accepted.