https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs

BOOK Notes: Test-Driven Development By Example

Money Example practice repo

  • Start simply
  • Write automated tests
  • Refactor to add design decisions one at a time

reference Money Example exrcise

Stratagies

Following are two of the three strategies I know for quickly getting to green:

  • Fake It— Return a constant and gradually replace constants with variables until you have the real code.
  • Use Obvious Implementation— Type in the real implementation.
  • Triangulation

    Triangulation

When the design thoughts just aren’t coming, Triangulation provides a chance to think about the problem from a slightly different direction. What axes of variability are you trying to support in your design? Make some of them vary, and the answer may become clearer.


Why Bank.reduce instead of Money.reduce (echange)

Money reduced= bank.reduce(sum, "USD");
// vs
...reduce= sum.reduce("USD", bank)

  • Expressions seem to be at the heart of what we are doing. I try to keep the objects at the heart as ignorant of the rest of the world as possible, so they stay flexible as long as possible (and remain easy to test, and reuse, and understand).
  • I can imagine there will be many operations involving Expressions. If we add every operation to Expression, then Expression will grow without limit.

Leave a comment