Skip to content

Level 2 of the Expense Report Legacy Code Refactoring Kata. Someone added a new feature (HTML output) without refactoring a bit!

Notifications You must be signed in to change notification settings

christianhujer/expensereport-level-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpenseReport Level 2

** WARNING! ** This repository will be rebased and force-pushed whenever there is a change to the (Level 1) ExpenseReport at https://github.com/christianhujer/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.
  • Add JSON as an output format.

History

So you looked at the Expense Report code. And you knew you had to refactor it. But you didn't. You left it as it is.

Weeks later, you revisit the code, and notice that it's gotten worse. A colleague has added a new feature, output in HTML, without refactoring the code. It's a real mess. And you gotta work with it now.

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 features.

Supported Languages

The ExpenseReport Level 2 kata currently exists in the following languages:

Incomplete

These languages are incomplete on Level 2:

  • BASIC (Commodore BASIC, Commodore 64)
  • BASIC (Locomotive BASIC, Amstrad CPC)
  • Go

Planned languages

(in no particular order and with no guarantee)

  • Eiffel
  • Elm
  • Erlang
  • Logo
  • Modula-2 (once the linker starts working again)
  • Oberon
  • R

Languages explicitly not planned

  • Brainfuck
  • Malbolge
  • Whitespace

Solutions

To see solutions, switch to the branch solutions.

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

Level 2 of the Expense Report Legacy Code Refactoring Kata. Someone added a new feature (HTML output) without refactoring a bit!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published