CPSC 480-020 Software Engineering (SE) Fall 2025

Exercise 58: Team Replace Nested Conditional with Guard Clause Refactoring Posted: Nov 13

Make sure you are in section 020. If not, then get to the assignment from your section of the course.

The function processOrder() has a calculation to process orders. It has error codes for each restriction, including if the quantity is non-positive, if the order is empty, if the product name is invalid, and if the quantity exceeds the maximum.

In this exercise, you will perform the refactoring Replace Nested Conditional with Guard Clause and then change the functionality.

Commit messages must be exactly as given in the instructions.

Report

Instead of an upload to Brightspace, you are going to fill out a form. You must fill it out after completing the commits and issue work of the following.

Perform Refactoring

  1. Create an issue at GitHub with the title Replace nested conditional with guard clause. This must be done first.
  2. Create a branch named refactor of the original code.
  3. In the branch refactor, perform a Replace Nested Conditional with Guard Clause Refactoring.

    As you make changes, build and run the test program often to ensure you are not changing the code's behavior.

    Commit your changes with the commit message:

    Push as soon as you make the commit.

  4. Close the issue at GitHub

Remove a restriction on branch refactor

  1. Create an issue at GitHub with the title Remove the restriction of an empty order on refactor. This must be done first.
  2. Move to the branch refactor.
  3. The customer wants to allow empty orders. Change the code, comments, and test to remove the error for an empty order.

    Make sure the program builds and that all tests pass.

    Use the following commit message exactly as given:

    Push as soon as you make the commit.

  4. Close the issue at GitHub

Remove a restriction on branch main

  1. Create an issue at GitHub with the title Remove the restriction of an empty order on main. This must be done first.
  2. Move to the branch main.
  3. The customer wants to allow empty orders. Change the code, comments, and test to remove the error for an empty order.

    Make sure the program builds and that all tests pass.

    Use the following commit message exactly as given:

    Push as soon as you make the commit.

  4. Close the issue at GitHub

Report

After completing the previous work, fill out this form.