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¶
-
Find all references to Hand’s
value()
method (usingCMD+B
orCTRL+B
for find usages), then extract (using Extract Method) and move that behavior (using Move Instance Method) into theHand
class. You may need to use the Introduce Parameter refactoring. -
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!