CPSC 480-020 Software Engineering (SE) Fall 2024

Exercise 54: Team Replace Nested Conditional with Guard Clause Refactoring Posted: Nov 12

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, fill out this form. Note you can edit it later, so get as much of the form filled out as possible during class time.

Perform Refactoring

  1. Create a branch named refactor of the original code.
  2. 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.

Remove a restriction on refactor

  1. Move to the branch refactor.
  2. 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.

Remove a restriction on main

  1. Move to the branch main.
  2. 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.