watching a talk about something called the "gilded rose kata" so I look it up and my thoughts roughly in order are:

  • wtf is a kata
  • wtf is a "code dojo"
  • why are you storing current time-to-expiry and quality and mutating them that's a fantastic way to introduce all kinds of inconsistency and corruption and fucked up desynchronization bugs
  • this problem is badly underspecified and in some places explicitly self-contradictory. what happens to the quality of conjured cheese? one rule says quality is never above 50 but another rule says this one item is always quality 80. also it never expires so what's the correct thing to do with the SellIn field?
  • [now looking at the python code] why is this a class? there is no reason for this class to exist. this is just a function.
  • why is this function iterating over a list? just process a single item and let the caller worry about how items are organized

none of this is what the exercise is actually about, which is iteratively refactoring the ugly code inside that function (er, method). but you know what I've been down this road enough times to know that iteratively refactoring code like this is likely to be a huge waste of time; you'll spend more effort preserving the almost certainly buggy behavior than you would by outright rewriting it.

the underspecification comment also applies to questions like:

  • do the after-expiry rules apply when SellIn reaches 0 or at the end of day during which it was 0?
  • should the quality rules be evaluated using the old or new value of SellIn?

(I don't actually care about the answers to these questions, I'm just saying that I question the value of an exercise whose explicit premise is "don't worry about the specification or the design of the points of interaction with the rest of the system, focus on improving the implementation," because frankly I think most developers need to work on the former a lot more than the latter. a spaghetti function is localized suck; imprecise specification and half-assed interface design are global problems)

I think the point the exercise is trying to make is "sometimes the specification you have isn't good enough, the existing code is the source of truth for disambiguating it, and you really have to refactor instead of rewriting to preserve that behavior," which, fair I guess.

@sjolsen unfortunately i have worked on projects like this and they are generally a good sign that you should start sending resumes

Follow

@sjolsen at least it was a hardware specification and we had real hardware to test our code against, but still, good god

Sign in to participate in the conversation
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!