August 2014
Beginner to intermediate
216 pages
5h 13m
English
The two lists of data values that HQ asked us to get—cheese consumption and W75 deaths—form two objects that are very similar. They seem to be two instances of the same class of things.
In this case, the class of things seems to have annual statistics. They're collections with a consistent structure of a year and a measurement. Both these annual statistics objects have a common set of operations. Indeed, the operations are pretty tightly bound to the measurement, and they are not at all bound to the year number.
Our collection of statistical functions is not very tightly bound to our data at all.
We can improve the binding between data structure and processing through a class definition. If we define the general ...