September 2016
Intermediate to advanced
454 pages
9h 23m
English
Some exercises have already been suggested in various sections of this chapter. Try those exercises. For example, split the unit tests so that you have separate modules for testing functionality from different classes. Add more unit tests to improve the code coverage. Also, try running nosetests on the tests that we have already written.
There are several low-hanging fruits for refactoring! Review the AttackOfTheOrcs._occupy_huts method. It creates hut objects, and puts an occupant in each of them. As the first step, you can rename it create_huts. The code in this method could be better written. It uses if...else conditions to decide which occupant to create. Although it works in this simple application, ...
Read now
Unlock full access