This kata comes from Saleem Siddiqui 's book
We have to build a spreadsheet to manage money in more than one currency : perhaps to manage a stock portfolio ?
Stock | Stock exchange | Shares | Share Price | Total |
---|---|---|---|---|
IBM | NASDAQ | 100 | 124 USD | 12400 USD |
BMW | DAX | 400 | 75 EUR | 30000 EUR |
Samsung | KSE | 300 | 68000 KRW | 20400000 KRW |
To build it, we'd need to do simple arithmetic operations on numbers :
5 USD x 2 = 10 USD
4002 KRW / 4 = 1000.5 KRW
// convert
5 USD + 10 EUR = 17 USD
1 USD + 1100 KRW = 2200 KRW
- We can use this table to determine exchange rates :
From | To | Rate |
---|---|---|
EUR | USD | 1.2 |
USD | EUR | 0.82 |
USD | KRW | 1100 |
KRW | EUR | 0.0009 |
EUR | KRW | 1344 |
KRW | EUR | 0.00073 |
We have already started the implementation by using TDD. We have discovered examples that helped us drive our implementation.
Money Calculator :
✅ 10 EUR x 2 = 20 EUR
✅ 4002 KRW / 4 = 1000.5 KRW
✅ 5 USD + 10 USD = 15 USD
Bank implementation :
✅ Determine exchange rate based on the currencies involved (from -> to)
✅ Improve the implementation of exchange rates
✅ Allow exchange rates to be modified
You will have to develop using the main constraints:
- Test-Driven Development
- Pair Programming
We will work in small iterations
- Share the constraint
- Implement it in your code
- Debriefing
- How did you apply it?
- What did you learn?
- How could it be useful in your current code base?
- Our solution
- Keep your code or switch to our solution branch to move on
In this workshop, we will make those iterations in this order:
- Let's Mutate Some Code
- Implement Portfolio
- Fight Primitive Obsession
- No For Loops
- Use Only Immutable Types
- Avoid Exceptions
- Use an existing monad
- Property-Based Testing to challenge our Domain Model
- Shared understanding on the Bank with Example Mapping
- Redesign the Bank
- Add an Acceptance Test
- Functional Core, Imperative Shell
We have created 1 branch per iteration solution
Each branch contains:
- a possible
solution
for the given constraint injava
,c#
andscala
- a
step-by-step
guide to reproduce how we came from previous state to the state in the branch- 1 guide per language in
<language>/docs/<#iteration>.<constraint>.md
- 1 guide per language in