Use Cases for a Simple Address Book

In the following, use cases are listed in the natural order that a user would think of them. In the actual File menu, items that correspond to the various use cases will be listed in the traditional order, which is slightly different.

[ UML Use Case Diagram ] Add a Person Use Case Edit a Person Use Case Delete a Person Use Case Sort Entries by Name Use Case Sort Entries by ZIP Use Case Find Text Use Case Find Text Again Use Case Print Mailing Labels Use Case Create New Address Book Use Case Open Existing Address Book Use Case Save Address Book Use Case Save Address Book As Use Case Quit Program Use Case Offer to Save Changes Extension

(Click on a use case above to go to the flow of events for that use case)


Flows of Events for Individual Use Cases


Add a Person Use Case

The Add a Person use case is initiated when the user clicks the "Add" button in the main window. A dialog box appears, with title "Enter new Person", containing fields for the user to fill in the new person's first and last names and other information. The box can be dismissed by clicking either "OK" or "Cancel". If the "OK" button is clicked, a new person is added to the end of the address book, and the person's name is added to the end of the list of names in the main window, and the "Save" option in the File menu is enabled. If the "Cancel" button is clicked, no changes are made either to the address book or to list of names in the window or its File menu "Save" option. An attempt to add a person with the exact same first and last name as that of an existing person (case-sensitive) will result in an error dialog instead.


Edit a Person Use Case

The Edit a Person use case is initiated when the user either highlights a name in the list of names in the main window and then clicks the "Edit" button, or the user double-clicks a name. In either case, a dialog box, with title "Editing person's name", appears containing current information about the person selected, (except the person's name, which appears only in the title). The user can then edit the individual fields. The box can be dismissed by clicking either "OK" or "Cancel". If the "OK" button is clicked, the entry in the address book for the selected person is updated to reflect any changes made by the user, and the "Save" option in the File menu is enabled. If the "Cancel" button is clicked, no changes are made to the address book or to the File menu "Save" option.


Delete a Person Use Case

The Delete a Person use case is initiated when the user highlights a name in the list of names in the main window and then clicks the "Delete" button. A dialog box appears, asking the user to confirm deleting this particular individual. The box can be dismissed by clicking either "Yes" or "No". If the "Yes" button is clicked, the entry in the address book for the selected person is deleted, and the person's name is deleted from the list of names in the main window, and the "Save" option in the File menu is enabled. If the "No" button is clicked, no changes are made either to the address book or to the window or its File menu "Save" option.


Sort Entries by Name Use Case

The Sort Entries by Name use case is initiated when the user selects the Sort by Name option in the Sort menu. The entries in the address book are sorted in ascending order by last name, and the list in the main window is updated to reflect this order as well. (In the case of two individuals with the same last name, the order is determined by ascending order of their first names.) Also, the "Save" option in the File menu is enabled.


Sort Entries by ZIP Use Case

The Sort Entries by ZIP use case is initiated when the user selects the Sort by ZIP option in the Sort menu. The entries in the address book are sorted in ascending order by ZIP code, and the list in the main window is updated to reflect this order as well. (In the case of two individuals with the same ZIP code, the order is determined by name order as in the "Sort Entries by Name" use case.) Also, the "Save" option in the File menu is enabled.


Find Text Use Case

The Find use case is initiated when the user selects the Find option in the Search menu. A dialog box appears, asking the user to specify text to search for. The box can be dismissed by clicking either "OK" or "Cancel". If the "OK" button is clicked, the program begins searching for the specified text either just after the highlighted individual, or at the beginning of the address book if there if no highlighted individual. The program highlights the first person it finds for which the desired text is a substring of the person's name or any other field, and the "Find Again" option is enabled. (If no such person is found before the end of the address book, the program pops up a dialog indicating that no match was found.) If the "Cancel" button is clicked instead, nothing further is done.


Find Text Again Use Case

The Find Again use case is initiated when the user selects the Find Again option in the Search menu. (The Find Again option is disabled (grayed out) at program startup, or when an address book is first created or read from disk, or is changed by an Add, Edit, or Delete operation, or when the most recent Find or Find Again was unsuccessful. It is enabled when a Find succeeds and remains enabled through successive Find Again operations that succeed.) The program begins searching for the text specified for the most recent Find, just after the last individual found by the most recent Find or Find Again. The program highlights the first person it finds for which the desired text is a substring of the person's name or any other field. (If no such person is found before the end of the address book, the program pops up a dialog indicating that no match was found, and the "Find Again" option is disabled.)


Print Mailing Labels Use Case

The Print Mailing Labels use case is initiated when the user chooses "Print Mailing Labels" from the File menu. A file chooser dialog is popped up, which allows the user to specify a file to write the address book to. If the user specifies a file and clicks "Print", the name and complete address for each person in the address book is written out to this file (in their current order) in "mailing label" format. [ Recall that mailing label format includes the full name and complete address but not the phone number. ] (If attempting to write the file results in an error, a dialog box is displayed warning the user of the error.) If the user cancels the dialog or closes it without specifying a file, nothing is written. In any case, no information maintained by the program is changed.


Create New Address Book Use Case

The Create a New Address Book use case is initiated when the user chooses "New" from the File menu. If the "Save" option in the File menu is enabled, the Offer to Save Changes extension is executed first. Unless the user cancels the operation, or if the extension is not needed, a new empty address book is then created and replaces the current address book. This results in the list of names in the main window being cleared, the current file becoming undefined, the title of the window becoming "Untitled", and the "Save" option in the File menu being disabled. (NOTE: These conditions will also be in effect when the program initially starts up.)


Open Existing Address Book Use Case

The Open Existing Address Book use case is initiated when the user chooses "Open" from the File menu. If the "Save" option in the File menu is enabled, the Offer to Save Changes extension is executed first. Unless the user cancels the operation, or if the extension is not needed, a load file dialog is displayed and the user is allowed to choose a file to open. Once the user chooses a file, the current address book is replaced by the result of reading in the specified address book. This results in the list of names in the main window being replaced by the names in the address book that was read, the file that was opened becoming the current file, its name being displayed as the title of the main window, and the "Save" option in the File menu being disabled. (If the user cancels the file dialog, or attempting to read the file results in an error, the current address book, window, and "Save" option in the File menu are left unchanged. If the cancellation results from an error reading the file, a dialog box is also displayed warning the user of the error.)


Save Address Book Use Case

The Save Address Book use case is initiated when the user chooses "Save" from the File menu. If there is a current file, the current address book is saved to this file, and the "Save" option in the File menu is disabled, but the current address book and window list are left unchanged. (If attempting to write the file results in an error, a dialog box is displayed warning the user of the error, and the "Save" option is not disabled.) However, if there is no current file, the Save Address Book As .. use case is invoked in place of this use case.


Save Address Book As ... Use Case

The Save Address Book As ... use case is initiated when the user chooses "Save As ..." from the File menu, or when the user attempts to Save an address book for which there is no current file. A save file dialog is displayed and the user is allowed to choose the name of a file in which to save the address book. The current address book is saved to this file, the file to which it was saved becomes the current file for future "Save" operations, its name is displayed as the title of the main window, and the "Save" option in the File menu is disabled, but the current address book and window list are left unchanged. (If the user cancels the file dialog, or there is an error writing the file, the Save As ... operation is canceled, and no changes are made; if attempting to write the file results in an error, a dialog box is displayed warning the user of the error as well.)


Quit Program Use Case

The Quit Program use case is initiated when the user chooses "Quit" from the File menu, or clicks the close box for the main window. In either case, if the "Save" option in the File menu is enabled, the Offer to Save Changes extension is executed first. Unless the user cancels the operation, or if the extension is not needed, the program is terminated. (If the user chooses to save changes and then cancels this operation or it fails due to an error writing a file, the quit operation is cancelled as well.)


Offer to Save Changes Extension

The Offer to Save Changes extension is initiated from within the Create New Address Book, Open Existing Address Book, or Quit program use cases, if the "Save" option in the File menu is enabled (indicating that the current address book has been changed since the last successful New, Open, Save, or Save As ... operation was done). A dialog box is displayed, informing the user that there are unsaved changes, and asking the user whether to save changes, not save changes, or cancel the operation. If the user chooses to save changes, the Save Address Book Use Case is executed (which may result in executing the Save Address Book As ... Use Case if there is no current file). If the user chooses not to save changes, the original operation is simply resumed. If the user chooses to cancel, or cancels the save file dialog if one is needed, or there is an error writing a file, the original operation that initiated this extension is canceled as well.


Page of links for non frames-enabled browsers.

Valid XHTML 1.0!

Copyright © 2008, 2009, 2011 - Russell C. Bjork. Permission for non-commercial reproduction for educational use is hereby granted; all other rights are reserved. Faculty who wish to use a project similar to the one I use with this material can contact me at russell dot bjork at gordon dot edu for information about the code.