The ExpenseReport legacy code refactoring kata in various languages.
This is an example of a piece of legacy code with lots of code smells. The goal is to support the following new feature as best as you can:
- Add Lunch with an expense limit of 2000.
- 📚 Read the code to understand what it does and how it works.
- 🦨 Read the code and check for design smells.
- 🧑🔬 Analyze what you would have to change to implement the new requirement without refactoring the code.
- 🧪 Write a characterization test. Take note of all design smells that you missed that made your life writing a test miserable.
- 🔧 Refactor the code.
- 🔧 Refactor the test.
- 👼 Test-drive the new feature.
The ExpenseReport example currently exists in the following languages:
- C
- C#
- C++
- Clojure ⇐ This one was particularly painful to intentionally write poorly, I almost cried.
- COBOL
- Dart
- Fortran
- Go
- Groovy
- Java
- JavaScript
- Kotlin
- Pascal
- Perl
- PHP
- Python
- Raku (Perl6)
- Ruby
- Rust
- Scala
- Swift
- TcL
- TypeScript
- XML/XSLT
(in no particular order and with no guarantee)
- Ada
- Common Lisp
- D
- Eiffel
- Elixir
- Elm
- Erlang
- F#
- Haskell
- Julia
- Lua
- Modula-2 (once the linker starts working again)
- Oberon
- Objective-C
- Scheme
- Smalltalk
- Visual BASIC
- Brainfuck
- Logo
- Malbolge
- Prolog
- Whitespace
To see solutions, switch to the branch solutions.
Warning The solutions branch will be rebased!
I first encountered the ExpenseReport example during a bootcamp at Equal Experts. I also have seen the ExpenseReport example being used by Robert "Uncle Bob" C. Martin. I have tried to research its origins but so far I have failed. If you know who has first come up with this example, please get in touch with me.