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:
- Ada
- BASIC (Amiga BASIC, Commodore Amiga) โ Quite amazing! First BASIC without line numbers!
- BASIC (Bywater BASIC, Linux) (very similar to Commodore BASIC)
- BASIC (Commodore BASIC, Commodore 64)
- BASIC (Locomotive BASIC, Amstrad CPC)
- C
- C#
- C++
- Clojure โ This one was particularly painful to intentionally write poorly, I almost cried.
- COBOL
- D
- Dart
- Elixir
- F#
- Fortran
- Go
- Groovy
- Haskell
- Java
- JavaScript
- Julia
- Kotlin
- Lisp (Common Lisp)
- Lua
- Nim
- Objective-C
- Pascal
- Perl
- PHP
- Prolog
- Python
- Raku (Perl6)
- Rexx (tested with Regina Rexx and ARexx)
- Ruby
- Rust
- Scala
- Scheme
- SQL (Using SQLite3)
- Swift
- Smalltalk
- TcL
- TypeScript
- Visual BASIC
- XML/XSLT
(in no particular order and with no guarantee)
- Eiffel
- Elm
- Erlang
- Logo
- Modula-2 (once the linker starts working again)
- Oberon
- R
- Brainfuck
- Malbolge
- 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.