Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Let’s review the steps we went
through to get to the final MinuteHourCounter design. The process is typical
of how other pieces of code evolve.
First, we started by coding a naive solution. This helped us realize two design challenges: speed and memory use.
Next, we tried a “conveyor belt” design. This design improved the speed and memory use but still wasn’t good enough for high-performance applications. Also, this design was very inflexible: adapting the code to handle other time intervals would be a lot of work.
Our final design solved the previous problems by breaking things down into subproblems. Here are the three classes we created, in bottom-up order, and the subproblem each one solved: