13.1. The Next Step
"OK, what do you want next?" I asked Sam.
"A double cappuccino with latte," he replied eagerly.
"I meant for the system," I said.
"Oh, I'd like to get the charge system running, so I can bill customers monthly rather than for each rental. That will avoid leaving a lot of cash lying around the store. I also want to be able to offer discounts to frequent renters," Sam rambled on.
"OK," I said, "that sounds like two things. Which one do you want first?"
"Let's start with the charging part," he replied.
"We have at least two halves to that part: determining how much to bill the customer and then actually doing the billing. The determination part seems simpler: total up completed rentals and any late fees to compute a bill. The second part requires a bit more work. You need to sign up with an Internet-based credit card handler. That's another external interface, but a much more interesting one. You can't just test against that database willy-nilly. You don't want to charge customers for things they haven't bought," I stated.
"We need a new class. The one-line definition of this class is 'A charge to a customer for rentals during a period of time.' What do you want to call this class: Invoice or Bill?" I asked.
"I have a brother named Bill. So let's call it Invoice or else I'll get confused," he answered.
Here is the class that Sam and I created:
class Invoice Customer the_customer InvoiceDetail the_detail Dollar total submit_for_payment( ) create_invoice_detail( ...
Get Prefactoring now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.