Here we consider two designs for a phone book application.
phone book as a "kind of" list by sub-classing a List entity. It
considers the phone book a list of contacts where each contact is a
pair of data (name, phone number). List is an abstract entity
that is augmented to perform phone book data management. Design B
utilizes composition where the phone book uses a list of contact objects.
The design requirements are:
A contact is name and phone number
Must be able to display all the contacts in the book
Must be able to look up a contact phone number by name or a name by phone number
Add, delete, edit contact
In terms of design specifications, design quality, or evolutionary requirements:
Should be able to add more information to a contact such as email, picture, etc.
Can manage multiple phone books
Phone Book Designs
of List: List class is extended to specifically manage contact
data as needed. The PhoneBook is the collection of Contacts.
Composition using List: PhoneBook uses a List as a collection of Contact objects. It does not extend the functionality of List.
Compare the two designs below by selecting which design is the "best" answer to the question asked.