Skip to content

The ExpenseReport legacy code refactoring example in various languages

Notifications You must be signed in to change notification settings

timvancleef/expensereport

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpenseReport

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.

Process

  1. 📚 Read the code to understand what it does and how it works.
  2. 🦨 Read the code and check for design smells.
  3. 🧑‍🔬 Analyze what you would have to change to implement the new requirement without refactoring the code.
  4. 🧪 Write a characterization test. Take note of all design smells that you missed that made your life writing a test miserable.
  5. 🔧 Refactor the code.
  6. 🔧 Refactor the test.
  7. 👼 Test-drive the new feature.

Supported Languages

The ExpenseReport example currently exists in the following languages:

Planned languages

(in no particular order and with no guarantee)

  • ABAP
  • Amiga E
  • AMOS BASIC
  • APL
  • More Assembler implementations (arm, aarch64, i686, powerpc, powerpc64, mpis, mips64, sparc, sparc64, risc-v, etc, usually on Linux)
  • Cluster
  • Dark
  • Eiffel
  • Elm
  • Erlang
  • Forth
  • Gosu
  • Hare
  • Logo
  • Modula-2 (once the linker starts working again)
  • Oberon
  • OCaml
  • R
  • REBOL
  • Scratch
  • WebAssembly

Languages explicitly not planned

  • Brainfuck
  • Malbolge
  • Whitespace

Solutions

To see solutions, switch to the solutions branch.

Warning The solutions branch will be rebased!

Credits

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.

About

The ExpenseReport legacy code refactoring example in various languages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Assembly 11.7%
  • Kotlin 6.0%
  • Makefile 5.6%
  • BASIC 4.6%
  • TypeScript 3.3%
  • Shell 3.2%
  • Other 65.6%