Refacto - GradedJestRisk/kata GitHub Wiki
Steps:
- before try to add new behaviour, check if it can be easily done
- if not, consider refactoring existing codebase to
- do your change easily afterwards
- understand the actual behavior and solving any contradictions between existing and new business rules
- to refactor an existing codebase and not causing regressions, you need to test after each change
- the easiest way is to
- begin putting it under an automatic test harness
- then refactoring
- when you finish your refactoring, introduce your changes
- consider putting a git pre-commit hook that will run the tests (just in case)
- is there any test ?
- if so, run them
- run coverage and mutation tests
- run tests to cover missing part
- no tests at all, do characterization test
- write assertion on output, assert it wil be false
- run test
- replace the expected output by test actual result
- break dependencies
Overview:
- our goods are constantly degrading in quality as they approach their sell by date.
- system in place that updates our inventory (SellIn , Quantity)
- add selling a new category of items
Basics:
- sellIn : remaining number of days we have to sell the item (number of days before expiration date is reached)
- Quality : how valuable the item is
- At the end of each day, sellIn and Quality decreases
- is never negative
- is never more than 50
- its range is is ] 0; 50 ]
- Quality degrades twice as fast
-
Aged Brie
- increases in Quality the older it gets
-
Sulfuras
- never has to be sold
- its Quality is 80 and never decreases
-
Backstage passes
- like aged brie, increases in Quality as its SellIn decrease (concert approach)
- 10 days or less : increases by 2
- 5 days or less : increases by 3
- after concert (SellIn = 0): drops to 0
Add conjured items.
- “Conjured” items degrade in Quality twice as fast as normal items
List:
- change UpdateQuality method
- you can make the UpdateQuality method and Items property static
- do NOT change the Item class (including or Items property )