Noticed (and took) opportunity to eliminate another local variable in play(). It turns out the that original code had a bug in the prettye printing of times, showing 10:1 instead of 10:01. Fixed this bug, which changed the expected value of the characterization test testConsoleOutput. In a prodution setting, this change would require additional investigation to make sure no client code is depending on the original (wrong) behavior.
- song collection is documented by the type system - got rid of ugly casts - got rid of Integer wrappers - simplified play() - simplified totalDuration() If the original characterization test (testConsoleOutput) is doing its job, this refactoring is behavior-neutral. This is a pretty agressive refactoring to make without new tests. Unless you are pretty confident, you might want to write some additional unit tests during this step.
…s does today, without trying to judge what the class should do. This test will allow us to refactor without breaking existing behavior. Note that this is not a unit test, and takes a black box view of the entire code under test. We will want more focused tests later. I generated the expected value by letting the test run once, then copying the actual value that came out.