M225: Software Engineering

Unassessed Coursework 4: A Library System

The aims of this tutorial are to enable you to practice specifying:

» systems that use collections of, and associations between, objects of different types;

» aspects of system architecture, such as local vs central control of object associations.

These questions are about specifying a Library system, used to control the operations of borrowing, and returning books to a library. The system includes a collection of objects of type Book and a collection of objects of type Borrower.

  • An object book has an ISBN number (sequence of char), a location (sequence of char) and a status (in or out).
  • Each borrower has an id code (sequence of char), and an upper-limit on the number of books that he/she can borrow.
  • At the beginning all the books are in the library.
  • Only one book at the time can be borrowed or returned.
  • Borrowing a book and returning a book changes the status of the book.

(Q1) Write an ObjectZ specification of the system Library using the local control approach to
specify the association between borrowers and books.

» The class schema Book should include the attributes defined above, two operations for
changing the status of a book, and any additional operation required to specify the local control.

» Assume the class schema Borrower to be responsible for the local control of the association between borrower and books borrowed. This class schema should include the attributes defined above and the operations BorrowOK, BorrowDenied, ReturnOK, ReturnDenied. Specify all the necessary pre-conditions.

» The class Library should include a set of books and a set of borrowers. Note that all the books borrowed by a borrower must belong to the library. This class should also include two operations: Borrow and an operation Return.

(Q2) Consider now a central control approach to specify the associations between borrowers and
books.

» Which class schema from answer to (Q1) above will not need to be changed, and why?

» Where needed write the new class schemas for the specification of the Library system using instead the central control approach. Assuming the same basic requirements for the objects Book, Borrower and Library.