CPSC 329 Software Development Fall 2026

CPSC 329 Lab 5: Refactoring and Issue Tracking

This lab introduces Eclipse's automated refactoring tools and the use of GitHub issues to track work. You'll be given a program along with a code review which has already identified a number of code smells — your job is to turn the review into tracked work (issues, a milestone, and a backlog) and then fix the problems, one issue at a time, each on its own branch and merged with a pull request.

Objectives

Successful completion of this lab means that you:

Collaboration and AI

Labs are for learning and practice — you may help and be helped by others when it comes to figuring out what to do, but in the end you need to understand and be able to do the things for yourself.

This lab is individual — everyone works with their own repository and does their own refactoring.

You may not use AI to figure out what to do or to do the task for you.

Due Date, Deliverables, and Handin

due Fri 10/2 at the start of class

To hand in your work:


Preliminaries

Provided Code

You'll be working with a console version of Klondike solitaire. Game runs the game; Card, Deck, Foundation, and TCol (a tableau column) are the pieces; Klondike contains main.

There is also a JUnit test suite. This test suite is your safety net — a refactoring changes the structure of the code but not its behavior, so tests which pass before a refactoring should still pass after it. Run the tests after every refactoring step to help ensure that nothing broke during refactoring.

The Code Review

Each finding in the provided code review identifies a smell, where it is, why it is a problem, and what the fix should be. The review refers to the code as it was reviewed — names like TCol in later findings refer to the class you'll have renamed by then.

Issues, Milestones, and the Backlog

Each finding in the review will become a GitHub issue. The required issues go into a milestone — a set of issues you're committing to finish by a date. The other issues stay in the backlog — open issues with no milestone, recorded but not scheduled. Each issue is fixed on its own short-lived branch in small commits (with the tests passing at each one) and is merged into main with a pull request which closes the issue.

For this lab, findings 1-6 are required (and will go into the milestone) while findings 7-12 are optional (address them if you have time) and will go into the backlog.


Setup

Creating the Project and Repositories

Start the same way you'd start any Eclipse project with Git, by creating the Eclipse project and sharing it to a local Git repository:

Then create a GitHub repository and connect your local repository:

Configuring the GitHub Repository

Labels categorize issues, and a milestone groups the issues that need to be done by a particular date. Set up the labels and milestones for this lab:

On the main repository page on github.com:

Turning the Review Into Issues

Each of the findings in the code review is something to fix, so create an issue for each in order to track progress:

On the main repository page on github.com:


Refactoring

Process

Workflow

Handling each issue follows the same remote repository workflow process as in lab 4:

Refactoring in Eclipse

Eclipse's refactorings are in the Refactor menu (also on the right-click menu); Alt+Shift+T pops up the refactorings that apply to the current selection. A few things to keep in mind:

Tasks

Fix the issues in numerical order (i.e. as listed below). Look at the code review as you start on each issue so you know what the refactoring steps are fixing. Refer to the workflow outlined above for the process steps; only specifics for the refactoring fix for each issue are given below.

Issue 1: Unclear Names — Rename

This refactoring makes use of Refactor → Rename to rename things (classes, methods, parameters, variables).

Issue 2: Game.play() is Too Long — Extract Method

This refactoring makes use of Refactor → Extract Method to turns the selected statements or expression into a new method. Eclipse automatically determines what the new method needs as parameters and what it should return.

Issue 3: Duplicated Input Loop — Extract Method

Extract Method can also find other copies of the selected code and replace them with calls to the new method.

You've found a bug. Don't fix it here — a refactoring doesn't change behavior while a bug fix does, so they belong in separate commits and pull requests, each reviewed for what it is. Instead, file a bug report so it isn't lost:

Issue 4: Feature Envy — Extract Local Variable and Move

Issue 5: Different Names for the Same Operations — Rename and Extract Interface

Issue 6: Game Does Too Many Jobs — Extract Class and Move

All six of the required issues in the milestone should now be closed. But don't close the milestone itself yet! Work on the additional issues below if you have time in lab, and then go to the Wrapping Up section at the bottom before handing in your lab.


Additional Issues

This section is optional, but is encouraged for additional practice — continue with it until the end of lab.

Before starting each additional issue, pull it into the milestone (set its milestone to lab 5 checkoff) — it's now being worked on and no longer in the backlog. This means that the milestone will accurately reflect what actually got done.

For each issue, follow the same workflow. Only the refactoring/editing steps are given below — remember to still start with an up-to-date main and create a new branch before starting on the issue and push, open a pull request, and merge when you are done.

The Bug from Issue 3 — Test First, Then Fix

Issue 7: Long Parameter List — Change Method Signature and Introduce Parameter Object

Issue 8: Insider Trading — Encapsulate Field, Extract Method, and Move

Manual refactoring — if Eclipse doesn't properly keep the reference to the cards_ with the automatic refactoring, make the changes yourself:

Issue 9: Magic Numbers — Extract Constant and Move

Issue 10: Scoring Spread Across Classes

Use References → Project on score_ and on revealTop to find everywhere that scoring happens, then collect the rules in a Score class as the review describes. Extract Class on score_, followed by Extract Method and Move, will get you partway. Change Method Signature can change revealTop's return type to boolean, and then the compiler will point out everything that needs fixing, including three tests.

Issues 11 and 12: Middle Man and Dead Code — Inline and References

Do these together on one branch — a pull request can close more than one issue.


Wrapping Up

At the end of lab, if any of the original six issues are still open, finish those. If you partway through an additional issue, finish it. Then close the milestone: