emilybache / GildedRose-Refactoring-Kata

Starting code for the GildedRose Refactoring Kata in many programming languages.
https://youtu.be/Mt4XpGxigT4
MIT License
3.77k stars 5.21k forks source link

Aged Brie getting 2 points per time step ? #195

Closed yanntm closed 3 years ago

yanntm commented 3 years ago

Hi,

I'm wondering if this is normal or not, the code provided does +=2 on the quality of "aged brie" at each step, which the requirements don't seem to express.

It's not obvious in the source code, but after refactoring in my solution (without touching semantics) it was glaringly obvious.

There are two updates to quality :

I thought the kata was about the new feature, but that existing code was supposedly semantically correct.

thanks for the work on these kata.

emilybache commented 3 years ago

Well spotted! Yes the code does some things that aren't fully documented. It's supposed to be legacy code after all 👍 You can basically assume that anything the code does is correct. It's in production, the Gilded Rose Inn is using it. If there is a conflict with the requirements, trust the code in preference.

Happy you had a go at the exercise!

Emily

yanntm commented 3 years ago

Ok thanks ! I'm kind of into formal verification, so I tend to trust the specifications too much, I mean Brie does get a lot smellier each day in the fridge, and I live in France :) So, it fits.

mikalziane commented 3 years ago

Good to know about this hidden "feature" Emily. Is it possible that someone updates the requirements then? I am also wondering if the different implementations (in several languages) share the exact same requirements. Unless I misunderstood something your reply suggests that this is not the case or someone would have to make sure all the implementations agree.

emilybache commented 3 years ago

No, the requirements are perfect for the excercise exactly as they are.

mikalziane commented 3 years ago

I have problems understanding the exercise. You say "if there is a conflict with the requirements, trust the code in preference." and " the requirements are perfect for the exercise exactly as they are." Obviously they are not "perfect" if code supersedes them so I have to understand what "perfect for the exercise" means unless the point is for the requirements to be misleading on purpose. Is this the case? If they are not why keep inconsistency between code and the requirements?

emilybache commented 3 years ago

Yes, this is an exercise that is supposed to be like real life. The requirements and code and any inconsistency between them is deliberate and part of the exercise.

mikalziane commented 3 years ago

OK then, thank you for the clarification. I'll take the "requirements" as a mere comment on the code then as they are supposed to be in real life ;-)

soryy708 commented 1 year ago

It was a surprising discovery, but I see how it makes sense from the requirements as written.

"Aged Brie" actually increases in Quality the older it gets Once the sell by date has passed, Quality degrades twice as fast

These two specifications together mean Aged Brie gets 2 points once the sell by date has passed.

But hey, spoilers!