The code for Chapter 13 of Beck has been added to GitHub with the following commit message:
Ch 13: Make It
There was data duplication initially, because we had a test that was passing because of a hardcoded response in the reduce method of the Bank class. It was returning 10 – so when a test was written for the Bank reduce, and written in a way that it had a different value expected, it caused us to be forced to correct the situation.
We started to work forward to find the implementation – breaking tests as we went, and refactoring by introducing the Sum class, until it passed at some level.
It passed – though the code had some casts that were pretty unappealing – and ths seemed to call out for polymorphism as the solution. As a result, the method “reduce (String paramName)” was introduced into the Money class, so that it could be put into the Interface class Expression. This lead to a cleaner implementation of the Bank’s reduce method.