Incremental Development
TheBasketball
class is extremely simple and it is likely to be
obvious to you how to complete it. (Or, you might remember from lab 2.)
But let's finish it by doing the following.
- Add instance variables to the basketball class representing the diameter and inflated status. Initialize them in the constructor.
- Re-run the unit tests. Are more of the tests passing now?
- Fix the
isDribbleable
method. - Re-run the unit tests. Are more of the tests passing now?
- Fix the inflate() method.
- Re-run the unit tests. Is everything passing now? When all the tests pass, the horizontal bar should be green instead of red. Victory!
Test early, test often!
The process we just went through in finishing theBasketball
class is a tiny example of
incremental development. This is just a strategy of developing code by making small changes
and testing frequently to ensure that the changes you made are working (and haven't
broken some other code that was working before). Effective programmers almost always use some form of
incremental development.
A framework like JUnit is invaluable for an incremental development strategy because it takes almost no work at all to re-run the unit tests and evaluate the results.
Checkpoint 1
- Show the TA your JUnit test and demonstrate it on your finished basketball class.