5 - Data Representation: A Case Study
Published online by Cambridge University Press: 05 June 2012
Summary
Informal Specification
Professor Higgins wants to set up a small database to keep track of which students are enrolled in his course on computational metaphysics. He asks his programmer, Eliza Doolittle, to write a program that will allow him or his secretary to
add a student record to the database;
determine whether a particular student is currently enrolled; and
remove a student record from the database.
Students are to be identified by their student numbers.
Eliza considers the problem and points out that the specification is incomplete: what should happen if a student is “added” when he or she is already enrolled? Or if a student is “removed” when that student has not yet enrolled? Professor Higgins replies that he would never make such mistakes; however, because the system will also be used by his secretary, he agrees that such operations should produce appropriate warning messages to the user.
Eliza intends to structure the program as two modules: one to manage the data representation and the other to provide the user interface. She decides that it should not be the responsibility of the data-representation module itself to produce error messages to the user; the user-interface module should do this. But where should the errors be detected?
If the data-representation module is responsible for detecting errors, it would be necessary for the operations to return error flags or to raise exceptions, which would significantly complicate the interface between the modules.
- Type
- Chapter
- Information
- Specifying SoftwareA Hands-On Introduction, pp. 111 - 124Publisher: Cambridge University PressPrint publication year: 2002