Questions About the Example

One of our favorite reviewers wasn't so sure we had tested everything. He asked:

Can the Account Go Negative? How Negative?

Yes, clearly it can, because the balance method just adds up the transactions, without regard to their sign. Does that need a unit test? Not in my opinion, because it can't possibly break.

Does it need an acceptance test? Almost certainly.

Can an Account Have Fractions Less than One Penny?

The code doesn't say. What will determine the answer will be the class of the object that comes back from sending value to a Transaction. That might be something as simple as an Integer or a Float, but it is more likely some kind of monetary type. In any case, the answer isn't here in Account, but in that class. ...

Get Extreme Programming Installed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.