Skip to Main Content
Prefactoring
book

Prefactoring

by Ken Pugh
September 2005
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 28m
English
O'Reilly Media, Inc.
Content preview from Prefactoring

14.2. A New Development

Sam called me up in an excited voice. "I've got great news."

"What? The coffee shop is having a special on double lattes?" I asked.

"Are they? I'll have to head down there," he replied. "My news is that I've hooked up with some web sites that catalog CDs. When someone gets to a CD that I have in stock, the web site posts a message telling the user that they can rent the CD at my store. I give them a cut of the rental in return."

"That sounds interesting. Are you going into the mail order rental business?" I asked.

"Not yet. But I'm getting ready," he answered. "I need you to work out the details with the web guys."

14.2.1. The Interface Contract

I called up the maintainers for one of the CD catalog sites. We discussed the interface operation and how we were going to communicate with each other. We created an interface with a single method: show_availability_of_CD_release(UPCCode upc_code). We also agreed on using Web Services as the communication protocol.

The show_availability_of_CD_release( ) method in StoreCollection is going to be exposed to the outside world. That calls for another interface, ExternalServiceProvider, to keep external services separate from internal services. The module in Sam's system that receives the request is:

    interface ExternalServicesProvider
        StoreExternalDTO[] show_availability_of_CD_release(UPCCode upc_code)

StoreExternalDTO parallels the Store class. We make up a separate class so that we are free to alter the internal ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding Unittest.Mock

Understanding Unittest.Mock

Mario Corchero
Java™ Performance

Java™ Performance

Charlie Hunt, Binu John

Publisher Resources

ISBN: 0596008740Supplemental ContentCatalog PageErrata