see also here: Developers anonymous
In this version I will try to show the changes step by step.
git checkout master
This step is the origional code. This code is the code to be refactored.
git checkout step_1
This step handles moving of a major part of the responsibility of the processing to the correct place.
Ask yourself the question. Who is responsible for the updateQuality method actions?
git checkout step_2
Polymorphism baby! "One name to rule them all..."
git checkout step_3
Wrap primitives... "Tell don't ask!"
git checkout step_4
Look at me being beautiful code :-)
git checkout step_5
Went a bit overboard and eliminated the name property also.
git checkout step_6
We still had some "Feature Envy" by exposing the SellIn and Quality class by getter methods.