|
1 | 1 | # workshop-soft-eng |
2 | | -Hands-on workshop on good practices in software engineering |
| 2 | + |
| 3 | +Hands-on workshop on good practices in software engineering. We're going to have a look at TDD, Unit Testing, Refactoring |
| 4 | +and CI/CD. |
| 5 | + |
| 6 | +# Gilded Rose Refactoring Kata |
| 7 | + |
| 8 | +Today's workshop is based on a popular refactoring exercise you can find out more about [here](https://github.com/emilybache/GildedRose-Refactoring-Kata/tree/main). |
| 9 | + |
| 10 | +# Setup |
| 11 | + |
| 12 | +We recommend using [Intellij](https://www.jetbrains.com/idea/download/) as the IDE. |
| 13 | + |
| 14 | +You will have to install [Node](https://nodejs.org/en/download/package-manager) v18.20. This should also install `npm`, |
| 15 | +which is a Node packet manager |
| 16 | + |
| 17 | +You might also have to install [ts-node](https://www.npmjs.com/package/ts-node#installation), after you get Node. |
| 18 | + |
| 19 | +``` |
| 20 | +# Locally in your project. |
| 21 | +npm install -D typescript |
| 22 | +
|
| 23 | +npm install -D ts-node |
| 24 | +``` |
| 25 | + |
| 26 | +# Getting started |
| 27 | + |
| 28 | +**First, fork this repository and clone it on your device.** |
| 29 | + |
| 30 | +Then, install dependencies |
| 31 | + |
| 32 | +```npm install``` |
| 33 | + |
| 34 | +# Run the unit tests from the Command-Line |
| 35 | + |
| 36 | +We are using jest as a testing framework. |
| 37 | + |
| 38 | +To run tests: |
| 39 | + |
| 40 | +```npm run test:jest``` |
| 41 | + |
| 42 | +To run all tests in watch mode: |
| 43 | + |
| 44 | +```npm run test:jest:watch``` |
| 45 | + |
| 46 | +# Running the app |
| 47 | + |
| 48 | +You can run the application seeing how the `updateQuality()` function works: |
| 49 | + |
| 50 | +```npx ts-node test/golden-master-text-test.ts``` |
| 51 | + |
| 52 | +Or with the number of days as args: |
| 53 | + |
| 54 | +```npx ts-node test/golde-master-text-test.ts 10``` |
| 55 | + |
| 56 | +# Gilded Rose Requirements Specification |
| 57 | + |
| 58 | +Hi and welcome to team Gilded Rose. As you know, we are a small inn with a prime location in a |
| 59 | +prominent city ran by a friendly innkeeper named Allison. We also buy and sell only the finest goods. |
| 60 | +Unfortunately, our goods are constantly degrading in `Quality` as they approach their sell by date. |
| 61 | + |
| 62 | +We have a system in place that updates our inventory for us. It was developed by a no-nonsense type named |
| 63 | +Leeroy, who has moved on to new adventures. Your task is to add the new feature to our system so that |
| 64 | +we can begin selling a new category of items. First an introduction to our system: |
| 65 | + |
| 66 | +- All `items` have a `SellIn` value which denotes the number of days we have to sell the `items` |
| 67 | +- All `items` have a `Quality` value which denotes how valuable the item is |
| 68 | +- At the end of each day our system lowers both values for every item |
| 69 | + |
| 70 | +Pretty simple, right? Well this is where it gets interesting: |
| 71 | + |
| 72 | +- Once the sell by date has passed, `Quality` degrades twice as fast |
| 73 | +- The `Quality` of an item is never negative |
| 74 | +- __"Aged Brie"__ actually increases in `Quality` the older it gets |
| 75 | +- The `Quality` of an item is never more than `50` |
| 76 | +- __"Sulfuras"__, being a legendary item, never has to be sold or decreases in `Quality` |
| 77 | +- __"Backstage passes"__, like aged brie, increases in `Quality` as its `SellIn` value approaches; |
| 78 | + - `Quality` increases by `2` when there are `10` days or less and by `3` when there are `5` days or less but |
| 79 | + - `Quality` drops to `0` after the concert |
| 80 | + |
| 81 | +We have recently signed a supplier of conjured items. This requires an update to our system: |
| 82 | + |
| 83 | +- __"Conjured"__ items degrade in `Quality` twice as fast as normal items |
| 84 | + |
| 85 | +Feel free to make any changes to the `UpdateQuality` method and add any new code as long as everything |
| 86 | +still works correctly. However, do not alter the `Item` class or `Items` property as those belong to the |
| 87 | +goblin in the corner who will insta-rage and one-shot you as he doesn't believe in shared code |
| 88 | +ownership (you can make the `UpdateQuality` method and `Items` property static if you like, we'll cover |
| 89 | +for you). |
| 90 | + |
| 91 | +Just for clarification, an item can never have its `Quality` increase above `50`, however __"Sulfuras"__ is a |
| 92 | +legendary item and as such its `Quality` is `80` and it never alters. |
0 commit comments