In this exercise, you will go through a workflow to perform a refactoring. The overall process includes:

  1. Setting up an issue at GitHub
  2. Creating an issue branch
  3. Performing the Rename Method refactoring
  4. Creating a pull request
  5. Accepting the pull request
  6. Closing the issue
  7. Deleting the issue branch (but don't do)

The following workflow must be followed to receive credit. Use the exact same commit messages as shown.

Set Up the Issue

  1. Create An Issue In GitHub, create an issue in your repository for the refactoring. The title of the issue is: For the body of the messages, explain what you will do as well as possible.
  2. Assign Yourself to the Issue Once the issue is created, assign yourself to the issue. That way, others know you are working on the issue.

Set Up a Branch for the Issue

  1. Create an Issue Branch Instead of working on the branch main, you are going to work on the branch issue_n_ where n is the issue number, e.g., if the issue number is 1 then the branch name is issue1. First, make sure you are in the branch main. Then, create the branch: Branches can be created via GitHub. However, please create this issue via the command line.
  2. You have created a new branch locally, but it does not yet exist at GitHub. To do so, you need to push it to GitHub. When you do so, you will see an error message. Enter the command that it shows you.

Perform a Rename Method Refactoring

  1. You are going to perform a refactoring. At every commit, the code must compile, build, and produce exactly the same result.
  2. Create a new method declaration in the ToDoList.hpp file. This is not a definition, only the declaration. Compile the program and get it to build successfully. Once done, commit using the commit message: Push your changes to GitHub.
  3. Create a new method definition in the ToDoList.cpp file. This method definition will not have any contents and will return a 0. In other words, the shortest/smallest implementation that will get the program to build. Once done, commit using the commit message: Push your changes to GitHub.
  4. Copy the contents of the old method length() definition to the new method size(). Successfully build the program. Once done, commit using the commit message: Push your changes to GitHub.
  5. At this point, both size() and length() do the same thing. Now, change length() (the old method) to call size() (the new method). The definition of length() should only have the call to size(). Note that you must pass along the parameters and handle any return statements. Push your changes to GitHub.
  6. One-by-one, replace any calls of the method length() with a call to method size(). Again, this must be done one call at a time. After each change, compile, build, and run successfully. Commit each time using the git command: Push your changes to GitHub
  7. After all calls to length() are replaced, delete the definition (not declaration) of length() in ToDoList.cpp. Compile, build, and run successfully. Commit using the command: Push your changes to GitHub
  8. Now delete the declaration of length() from ToDoList.hpp. Compile, build, and run successfully. Commit using the command: Push your changes to GitHub.

At this point, the refactoring is complete.

Create a Pull Request

Create a pull request at GitHub. You want to pull from the branch issue1 into the branch main.

Accept the Pull Request

Accept the pull request at GitHub. Typically, this would be done by another team member, but in this case, you can accept your own pull request.

In your GitHub Codespaces or on your local machine, switch to the branch main and pull the changes. You should see the rename in the code on the branch main.

Close the Issue

  1. At this point, you have completed the issue and can close it. Do so at GitHub.

Delete the Branch

  1. The branch issue1 has done its job and is no longer needed. All your commits on this branch are now in the branch main.
  2. We could delete this branch, but do not do so for purposes of this assignment.