The Beverages Prices Refactoring kata: a kata to practice refactoring away from an awful application of inheritance.
Published by Manuel Rivero on 07/04/2019
I created the Beverages Prices Refactoring kata for the Deliberate Practice Program I’m running at Lifull Connect offices in Barcelona (previously Trovit). Its goal is to practice refactoring away from a bad usage of inheritance.
The code computes the price of the different beverages that are sold in a coffee house. There are some supplements that can be added to those beverages. Each supplement increases the price a bit. Not all combinations of drinks and supplements are possible.
Just having a quick look at the tests of the initial code would give you an idea of the kind of problems it might have: