A kata for cleaning up some 'unclean' code
The focus of the exercise is the ProductPriceCalculator
class.
Its job is to calculate the price of a product for a given user.
Each product has a name and a price and a name.
If a user is an employee they get 5% discount on all products.
The ProductDAO is essentially a mock database for product information, the UserDAO
In order to clean up the code, you should look for the following things
- poor naming
- repeated code blocks
- nested conditional blocks
- nested loops
- unexpected side effects
- superfluous comments
- misleading comments
- 'magic' numbers
- poor segregation of responsibilities
A test is provided that ensures the expected behaviour of the application remains in place. If you would prefer you can start by implementing this test from scratch, something would probably need to do in a real life scenario.