TDD by Beck – Chapter 13 code on GitHub

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.

Advertisements
Posted in TDD, Uncategorized | Leave a comment

TDD by Beck – CH 12 code on GitHub

The code for Chapter 12 of TDD by Beck is now on GitHub.

CH 12 - Addition, Finally

In this chapter, we take a big test - which is addition cross-currencies, and reduce it to a simpler case of addition in a single currency.

Wiht that - we have a metaphor - Expressions - which are currency independent - think of them like a wallet.  Operations result in expressions - and if we think of the multiple ways that a currency combination in a wallet can have the same value - we introduce a "bank" as a way of converting to a single currency value at the end.

This means - Expression will operation on Money.
Then create a bank.
Have the bank reduce the value to USD (for example)
Posted in TDD, Uncategorized | Leave a comment

TDD by Beck – Chapter 11 code on Git

The code for Chapter 11 (“The root of all Evil”) of TDD by Beck is now available on GitHub.

The commit notes on Git are as follows:

 

The intent is to remove the Dollar/Franc duplication.
Removed Dollar - and checked for references to Franc.
There were some - though the tests were sufficiently covered elsewhere that it was not worth keeping the testDifferentClassEquality.
At the same time the "testFrancMultiplication" - can be removed - though I would advocate keeping it, personally.

Beck says that no system confidence is lost if you remove it - and as the system is relatively well understood, that is okay, in more complex cases, this may not always be the case.
 Redundant code is important to remove at the same time - keeps things clean and limited to what you need, and what you want to spend time reviewing.
Posted in TDD, Uncategorized | Leave a comment

CH 10 of TDD

The code for Chapter 10 – “Interesting Times” – is not on GitHub.

Posted in TDD, Uncategorized | Leave a comment

Ch 9 of code for TDD

Currently on GitHub

Posted in Uncategorized | Leave a comment

Ch 8 code for Tdd now on GitHub

The code for Chapter 8 of TDD by Beck is now on GitHub.

Posted in TDD | Leave a comment

TDD by Beck – Chapter 7 code on Git

The code for Chapter 7 – Apples and Oranges has been checked into GitHub.

CH 7 – Apples and Oranges
Here, comparing Francs and Dollars (within the Equals) method was a curiousity that was on the task list.
It was an objection – so a test was created, which failed.
This meant getting to green – through a Java mechanism, not a domain (finance) mechanism.
A bit uncomfortable as a solution – but not enough of a motivation to refactor the design just yet – so it is not perfect, but it will suffice for now.

Feedback is welcome.

Posted in TDD | Tagged , | Leave a comment