Copyright by Kent Beck

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Chapter 13. Make It

$5 + 10 CHF = $10 if rate is 2:1$5 + $5 = $10

We can't mark our test for $5 + $5 done until we've removed all of the duplication. We don't have code duplication, but we do have data duplication—the $10 in the fake implementation:

Bank
					Money reduce(Expression source, String to) {
   return Money.dollar(10);
					}
				

is really the same as the $5 + $5 in the test:

public void testSimpleAddition() {
					Money five= Money.dollar(5);
					Expression sum= five.plus(five);
					Bank bank= new Bank();
					Money reduced= bank.reduce(sum, "USD");
					assertEquals(Money.dollar(10), reduced);
					}
				

Before when we've had a fake implementation, it has been obvious how to work backward to the real implementation. It simply has been a matter of replacing ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required