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

10.3. Interface Development

Sam and I did not have much time to discuss the new use cases introduced at the beginning of this chapter. The original Search_catalog use case in Chapter 4 seems to imply that the search should return only CDCatalogItems that Sam carries in inventory. Should that filtering be part of the CDCatalogItemCollection interface or should it be done on the list of CDCatalogItems that the interface returns?

Considering separation of concerns simplifies our decision. The job of the CDCatalogItemCollection interface is to find all CDCatalogItems that meet the search criteria for each method. The concern of another class, CDCatalogItemInStoreCollection, is to determine which CDCatalogItems correspond to CDReleases. The interface for CDCatalogItemInStoreCollection looks the same as that for CDCatalogItemCollection. CDCatalogItemInStoreCollection is responsible for checking that the UPCCode for each CDCatalogItem exists in the CDReleaseCollection and returns only CDCatalogItems for which that was true. Figure 10-1 shows the sequence diagram for a search using CDCatalogItemInStoreCollection.

Figure 10-1. CDCatalogItemInStoreCollection sequence diagram

To check the usability of the search interface, Tim and I create a small class that implements the CDCatalogItemCollection interface and returns data for a very small number of CDCatalogItems and Songs. Text ...

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