Monday, November 2, 2009

Design Considerations








 

 










Design Considerations



A more practical type of rolodex program would permit more than just the names and numbers to be stored in the phone book. You'd probably want to keep addresses (maybe even electronic mail addresses) there as well. The new rolo program allows entries in the phone book to consist of multiple lines. For example, a typical entry might be





Steve's Ice Cream

444 6th Avenue

New York City 10003

212-555-3021



To increase the flexibility of the program, we're allowing an individual entry to contain as many lines as desired. So another entry in the phone book might read





YMCA

(201) 555-2344



To logically separate one entry from the next inside the phone book file, each entry is "packed" into a single line. This is done by replacing the terminating newline characters in an entry with a special character. We arbitrarily chose the caret ^. The only restriction here is that this character not be used as part of the entry itself.



Using this technique, the first entry shown would be stored in the phone book file as





Steve's Ice Cream^444 6th Avenue^New York City 10003^212-555-3021^



and the second entry shown as





YMCA^(201) 555-2344^



You'll shortly see how convenient it becomes to process the entries when they're stored in this format. Now we'll describe each program written for the rolodex program.












     

     


    No comments: