10.2. Designing the Interface

At this point, Tim and I were not sure how we were going to obtain the data for the catalog. Sam had mentioned a couple of Internet sites where it might be available. I figured a CD-ROM or two probably was available with the data. After all, a CD-ROM with equivalent information exists for books. At worst, we might put his staff to work when they had nothing else to do. They could input the information from the CD cases.

How we were going to implement the catalog was irrelevant at that point. What we needed was the search interface. Based on the use cases given in the previous section, we came up with a rough class outline that looked like this:

    class Song
        CommonString the_title
    class CD
        UPCCode the_upc_code
        CommonString the_title
        Performer [] the_performers
        Song [] the_songs
        // Other Info to display (e.g. producer).
    class Performer
        Name the_name

Based on these classes, we developed the following interface. The return values are shown as groups (arrays). They could become collections if we started to add functionality to the groups (such as sort by producer).

    interface CDCatalog
        Song [] search_for_song_by_title(CommonString string_to_match)
        CD []  retrieve_cds_for_song(Song a_song)  // From the song list
        Performer [] search_for_performers_by_name(CommonString string_to_match)
        CD [] retrieve_cds_for_a_performer(Performer a_performer)
             // From performer list
        CD [] search_for_cds_by_name(CommonString string_to_match)

10.2.1. What's a CD?

Now, what ...

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.