Skip to content

Fix Hand Feature Envy

Depends on Hand class

This lab requires that you've completed the previous lab, extracting the List of Cards to a new Hand class that has a value() method. If you didn't get that far, you can pull the latest code from the repository and start from there.

Goal

Now that Hand exists as its own type, the related code smell, Feature Envy, becomes apparent. In this lab, you'll fix this code smell and write tests for the newly encapsulated behavior.

Run All Tests...

Make sure all the tests pass before you start.

Steps

  1. Find all references to Hand’s value() method (using CMD+B or CTRL+B for find usages), then extract (using Extract Method) and move that behavior (using Move Instance Method) into the Hand class. You may need to use the Introduce Parameter refactoring.

  2. With the time remaining, write as many new unit tests for the newly moved behavior.

Run All Tests...

Make sure all the tests pass when you are done.


You are done!