Skip to content

My take on Gilded Rose Refactoring Kata using TypeScript

Notifications You must be signed in to change notification settings

sitek94/gilded-rose-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gilded Rose Typescript

🚧   work in progress  🚧

Attempts

1. Violated Rules

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.

2. Heavily inspired by Sandi Metz

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:

  1. She uses Ruby, not TypeScript.
  2. 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 have items 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.

Resources

The exercise's content comes from emilybache/GildedRose-Refactoring-Kata repo.

RailsConf 2014 - All the Little Things by Sandi Metz

About

My take on Gilded Rose Refactoring Kata using TypeScript

Topics

Resources

Stars

Watchers

Forks