Check out the resources for this kata.
The main book for this kata is Joshua Kerievsky's "Refactoring to Patterns".
This kata is based on Emily Bache's version: emilybache/Product-Export-Refactoring-Kata.
- t-initial-setup
- This is what we'd find in a legacy code
- No tests
- t-tests-in-place
- System is under test
- t-test-for-different-tax-calculation
- Code coverage tool uncovered a different tax calculation algorithm
- t-first-test-refactoring
- Test code should also be refactored
- t-add-lombok-dependency
- We are Java developers of the modern age
- Some people will call it poor man's Kotlin. And they'd be right
- t-classes-lombokified-and-simplified
- Look at this removed code, oh my, the removed code!
- t-tax-calculator-under-test
- Tax calculation is tricky and expensive to break
- We have to make sure we didn't break anything
- t-ledger-introduced
- We finally got our domain expert
- How would you call something that holds a list of orders?
- t-ledger-renamed-to-account
- After further discussions, our domain expert says that it should be an Account.
- t-tax-calculator-removed
- But tax calculation is hard, we don't want to lose it!
- Don't worry, now the Account is responsible for it
- t-rtp-price-implicit-leaf-extracted
- Alright, finally we can do the refactoring to a Composite pattern
- Look at one of the commits
- It's very small
- There are a lot of such commits, so Pair Programming may be necessary
- t-strategy-pattern-in-product
- Introduction
- Implementation in StoreEvent
- That strategy pattern came out of nowhere!
- But it solved a problem of duplication at that time
- It turned out not to be useful later, so it was removed
- t-rtp-refactoring-to-composite-done
- What a journey that was
- The design is better, the tests pass after each commit, so we could continuously deliver it to production
- Better, shorter functions
- But still not declarative enough
- t-domain-objects-moved-to-domain-package
- Wait, why are there xml representations of domain objects in the objects themselves?
- You can argue that it is the domain of the project, because the project is solely for exporting XML
- t-rtp-xml-builder-implemented
- Luckily, we've got some spare time, so we'll make the design even better by implementing the Builder pattern
- t-rtp-encapsulated-composite-with-builder-in-price
- Now the design better reflects the intent
- It's more declarative instead of imperative
- t-rtp-simplify-price-after-encapsulation-with-builder
- Further simplification
- t-rtp-simplify-serialization-in-xml-exporter
- Further deduplication
- t-refactored
- That's much better
- Thankfully we did it in Pair Programming, because a PR for it would be huge!