13.2. The Language of the Client
Sam came by to discuss the discount mechanism that he was thinking about. He started talking. I was listening with a pen in hand. He said something like this:
"I want to give a 5% discount if a customer rented more than six CDDiscs in the past month and another 5% if he averaged more than five rentals in the last six months," he said, without pausing for a breath.
"Say again," I asked.
He replied at the same speed, as though he thought that if he did not get it out fast enough, he would forget it.
I took out a clean sheet of paper and copied down what I was pretty sure I heard:
Start with discount_percentage = 0.0.
- If (average_number_of_rentals_during_last_six_months > 5) discount_percentage = discount_percentage + 5.0
I asked him if this was what he meant. He looked at it and asked what the > symbol meant.
I told him that it meant, "is greater than."
He said, "Great, that's exactly what I want."
"Is this what you'll want forever?" I asked.
"Well, probably not," he replied.
"I'll tell you what; I'm going to let you maintain this code," I said. "If those numbers change, you just change the numbers and I'll add it to the program."
"So I'm a programmer now?" Sam asked.
"Of course. We're part of a team," I replied.
Suppose Sam were fairly sure that the algorithm was not going to change, but the numbers were going to change. Then a configuration file ...