CompSci 308
Fall 2016
Software Design and Implementation

Peer Code Review

You should know by now that code duplication is number one in the Code Smell stink parade. Still, as things need to get done, you rush and copy code anyway. In today's exercise, with a partner (not from your team), take some time to find copied fragments of code and refactor them to remove the duplication.

To work on this exercise, create a branch in your team's repository called duplicated_NETIDs, where NETIDs is your pair's Duke NetIDs. As a pair, you will refactor some duplicated code and describe your decision making process in a separate file using Gitlab's markdown format.

Resources

Using Google's tool CodePro AnalytiX, locate the duplicated code in your project. To save you time in class today, we ran it on each project and made the results available here.

You can install it from within Eclipse by going to this URL:

http://dl.google.com/eclipse/inst/codepro/latest/3.7

When installed, a new entry in your project's contextual menu (right clicking on your project) called CodePro Tools. Choose "Find Similar Code" to see an interactive report.

Code Smell Refactoring

To start, with your partner, agree on at least one section of code to refactor from each team's project (it does not necessarily have to be code you wrote). In your discussion file, describe why you choose this section of code to refactor.

Finding duplicated code is easy (so easy a computer can do it :), but refactoring it can take some thought. Sometimes the refactoring is as simple as creating a new method, sometimes it requires creating an inheritance hierarchy, sometimes a Design Pattern will help, or sometimes a new class or abstraction is required. Discuss the options as a pair and decide how best to refactor the chosen code section to remove the duplication. In your discussion file, describe why you chose the option you did and what, if any, alternatives you considered.

Checklist Refactoring

We also wrote a simple script to check some basic features of your code and made the results available here.

To start, with your partner, agree on at least one issue to refactor from each team's project (it does not necessarily have to be code you wrote). In your discussion file, describe why you choose this section of code to refactor.

CheckStyle

You can also run CheckStyle on your source code to find other issues and refactor your code based on issues it finds.

Submission

At the end of class, use Gitlab's Merge Request to submit your group's refactored code and your discussion file to each team's repository. Make sure both people's NetIDs are in the title of your Pull Request and that both people's names are in the discussion file.