🚧 work in progress 🚧
Code: Attempt 1
The description says:
(...) do not alter the Item class
And that's exactly what I did 🙈 I added updateQuality
method to Item class, so that when GildedRose
was
iterating over its items, it was invoking that method. This allowed each special item to have its own
version of updadeQuality
with some special conditions.
Conjured Item implementation works, but I'm not really happy with this solution.
Code: Attempt 2
In this approach I tried to apply what I learned by watching the talk by Sandi Metz. Copying her solution 1-to-1 is not possible, for number of reasons:
- She uses Ruby, not TypeScript.
- Her version of the Kata is a bit simplified, which in my opinion is understandable, because when you give a talk you
want to focus on the key concepts, and don't delve into some corner cases. Nevertheless, here are some differences:
- Her
GildedRose
class doesn't haveitems
that it iterates over, there is just one item being handled. - Some edge cases are not handled, e.g. in her implementation it'd be possible to increment the quality "Aged Brie" to 51.
- In her version a normal/common item has property name of "normal", whereas in original Kata, any item which name is not "Aged Brie", "Backstage passes", "Sulfuras" or "Conjured" is considered normal.
- Her
The exercise's content comes from emilybache/GildedRose-Refactoring-Kata repo.