In Christian Hujer’s Expense Report Legacy Code Refactoring kata, you get to inherit an existing codebase in need of a new feature. It, however, has no tests, and can’t easily be tested.
For this exercise, we’ll be mostly following Christian Hujer’s instructions that will have us discussing and taking notes as we go.
New Feature to Build
- Add Lunch as a meal expense with a limit of 2000.
- 📚 Read the code to understand what it does and how it works.
- 🦨 Read the code and check for design and code smells. Make a list of all code and design smells that you find.
- 🧑🔬 Analyze what you would have to change to implement the new requirement without refactoring the code.
- 🧪 Write a characterization test. Expand your list of code and design smells. Add those smells that you missed earlier and discovered now because they made your life writing a test miserable.
- 🔧 Refactor the code.
- 🔧 Refactor the test.
- 👼 Test-drive the new feature.
Here’s the link to the source code for this exercise.
- Christian Hujer’s repository of starting code in various languages: https://github.com/christianhujer/expensereport