CPSC 501 Assignment 1: Refactoring solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Instructions:

Find or create a running object-oriented Java program. You must have the proper
approval to use this codebase if it isn’t yours.

The program you use should be poorly
structured and able to be improved via refactoring. A recommendation is to pick code you
have written in the past, avoiding GUI-based code.

If you decide to write new code for this
exercise, some project suggestions are
ˆ Accounting or inventory systems for stores or other businesses
ˆ Employee management systems
ˆ Command-line games, e.g. tic tac toe

The program must consist of 5-10 classes that are coupled together to make the program function. These classes must also incorporate some sort of inheritance structure. For
example, there could be an interface that is implemented by two or more subclasses, or a
class that is extended by two or more child classes.

Upload this starting project as the initial codebase for a new GitLab project at gitlab-cpsc.
ucalgary.ca. You will receive instructions on how to use this system during the first week
of tutorials. Next, find aspects of the project that would benefit from refactoring and perform at least five unique refactorings (i.e. no two refactorings have the same name, so
you can’t just perform Rename Method five times). At least two of the refactorings must
result in substantial changes to the internal design of the system.

Each refactoring should be tracked using separate Git commits, and at least one of
the two larger refactorings should be completed using branch and merge Git commands.
These commits may be done on the local repository, but must then be pushed to the
remote repository. Make sure you document each refactoring with a meaningful message in
the version control system.

You must also perform JUnit testing as you do the refactoring. You will likely want
to add or modify tests as you refactor your code into smaller methods. The testing code
must also be kept under version control. This unit testing doesn’t have to cover the entire
project – a recommendation is to choose a couple operations from the initial project, design
simple unit tests for them, and then refactor the code relating to these tested operations.

This way, the unit tests provide feedback about whether your refactorings are preserving
functionality, without you having to write unit tests for the entire project.

Finally, you need to complete a written report that describes how you did your refactoring. For each of the five refactorings, your report should answer the following questions:
1. What code in which files was altered? Don’t include entire files, just the code snippets
that were relevant to the refactoring. Line numbers alone aren’t sufficient.

2. What needed to be improved, and why? List any “bad code smells” detected.
3. Which refactoring was applied? What steps did you follow? Use the terminology and
mechanics discussed in class or in the Fowler text.

4. What code in which files was the result of the refactoring? See point 1.
5. How was the code tested? Which JUnit test methods were applicable?
6. Why is the code better structured after the refactoring? This could be addressed
simultaneously with point 2.

Use SHA numbers to cross-reference your commits as you describe each refactoring.
Also make sure you indicate the refactoring that was required to use branch and merge.

In addition, at the beginning of the written report, you need to include directions for
the TA to access your GitLab project. This is how they will be able to access your
code, unit tests, and commit history, so double-check this works correctly before submitting.

The expected length of the report is about 2–3 pages with standard font and margins,
but there are no strict requirements. It is essential, however, that your report is clear, easy
to read, thorough, and written in complete sentences.

Submission instructions:
Upload your written report as a PDF file to the Assignment 1 dropbox on D2L by 23:59
on October 9th. The TAs will use the instructions in your report to access your GitLab
project, through which they will grade your submission.

Rubric (100 pts total):
ˆ Version control: Used Git/GitLab properly, Multiple small commits with informative
messages (25 pts)
ˆ Branch/merge: One branch and merge operation used for a larger refactoring (5 pts)
ˆ Unit testing: Tests are applicable to refactorings and test robustly for multiple points
of failure (15 pts)

ˆ Refactorings: Evidence in version control and report of five clear and systematic
refactorings. Two of these refactorings result in larger structural changes (25 pts)
ˆ Report: Description of each of the five refactorings answering provided questions.
Report is thorough and written in full sentences. (25 pts)

ˆ Communication: Clear, working instructions on how to access GitLab project. (5 pts)
Note that for this assignment, your work will be graded by your own lab TA. If you
have questions about the requirements or what is permitted, it is recommended you consult
with them directly during tutorial or through Piazza.