Ugly Trivia

Ugly Trivia

Each turn a player: rolls the dice and has to answer to a question from the deck corresponding to its current position. If the answer is correct [s]he gets coins. If incorrect, [s]he is sent to the prison. The board has 12 positions.

You should discover more the details from actual code, just like in real-life. Good luck!

Instructions

  • Download a version of the code to refactor in your language of choice.
  • Add the necessary tests to make sure you don't break the code while you refactor.
  • Improve the design by refactoring (without altering the behaviour of the code).

Golden Master Technique

We can’t write reasonable unit tests without refactorings first. But we don’t want to refactor without tests at all.

But we can test the application as a whole. Gain control over all external input sources (RNGs, system time, keyboard input and so on). Then save all outputs produced (console output, emails sent, files changed etc.). This is our Golden Master.

Now we can change the code and compare if it still yields the same results as before.

Code to Refactor

Credits