The actual business requirement says "5 minutes"... but being experienced at this kind of thing, we know that when requirements specify absolute values, those are usually the things that change. Taking it into account now is cheap and easy. Trying to account for it the week before launch, or when a legal report is overdue, expensive and painful. So they decided to parameterize it, and they came up with something that looked like:
Record.changed_in_last_x_minutes(5)
They looked at that for a minute and asked me what I thought. "It's not hateful..." I said, and they both laughed.
It was a diplomatic answer. We have all spent time in languages and projects where that would have been perfectly acceptable; but in the past few years, developers have spent a lot of time concerned about aesthetics, readability, and maintainability... and this just didn't seem to live up to that expectation. I was proud of them just for asking - most developers would have just coded it up and moved to the next problem.
"I'd like to have it read like a sentence, and that just doesn't do it for me", I said.
Arild said, "I agree... but the problem is trying to get the number value at the end of the sentence with the 'minutes' in there"... and both of our eyes lit up. I think I managed to verbalize it first, but we both had the same flash of insight... we wanted to pass in a duration, not a number.
Thirty seconds later, and we had an API that looks like:
Record.changed_in_last(5.minutes)
and that api also works now for variations like changed_in_last(2.hours), changed_in_last(47.seconds), changed_in_last(5.days), changed_in_last(2.weeks), and just about every variation you can imagine.
A brief conversation, a small insight, and an additional 30 seconds of code, and we have a fluent interface that can easily implement many requirement variations. We can also show to a client and ask "is this what you mean?".
It might seem like one small change, but these add up. Imagine an entire system designed that way - where the code begins not to read so much as code, but more like a formal description with a lot of flexibility... A system where the developers care what the names of things are and how they read with that attention to detail.
As soon as we had it done, I remembered this story by a friend of mine. I'm happy to steal his title and write this story as an homage to the point he so elequently made.