Use Case - Example
Use Case - Example
University library system requirements Books and journals the library contains books and journals. It may have several copies of a given book. Some of the books are for short term loans only. All other books may be borrowed by any library member for three weeks. Only members of staff may borrow journals. Members of the library can normally borrow up to six items at a time, but members of staff can borrow up to 12 items at a time. New books and journals arrive regularly, and old ones are sometimes disposed of. The current years journals are sent away to be bound into volumes at the end of each year. Borrowing it is essential that the system keeps track of when books and journals are borrowed and returned. The new system should also produce reminders when a book is overdue. There may in future be a requirement for uses to be able to extend the loan of a book if it is not reserved. Browsing this system should allow users to search for a book on a particular topic, by a particular author, etc., to check whether a copy of the book is available for loan and, if not ,to reserve the book. Anybody can browse in the library.
P. Stevens, R. Pooley. Using UML: Software Engineering with Objects and Components. Addison-Wesley, 2000.
Borrow journal Book Borrower Reserve book Return journal Borrow copy of book Journal Borrower
Browse
Browser
User interface
our task is to build the underlying system providing functionality which will be invoked through the user interface. separation between user interface and underlying system.
Identifying classes
Key domain abstractions Features and facts about the library which matter in the system
Candidate classes
Discard as candidate classes:
Library Short term loan loan is really an event, which, so far as we know, is not a useful object in the system Week measure of time, not a thing. Item vague. Clarify as either a book/journal.
Candidate classes
Book Journal Copy of book library member Member of staff
Dont need to get it absolutely right at this stage we are not trying to design the system, butt to identify the important real world objects within the domain of the system.
Book
Is a copy of 1 1..*
borrows/returns
LibraryMember 0..1 0..*
Copy
0..*
Journal
Book
Is a copy of 1 1..*
borrows/returns
LibraryMember 0..1 0..*
Copy
MemberOfStaff
Journal
Book
Is a copy of 1 1..*
borrows/returns
LibraryMember 0..1 0..*
Copy
Loan
MemberOfStaff
Further Revision?
Interaction Diagrams
UML uses interaction diagrams to show how messages pass between objects of the system to carry out some task To realize a particular use case Not needed for every use case. For a complicated use case, or to clarify which of several use case
realizations is better
Library member borrows a book In the physical world a human library member will come to the issuing desk with physical copy of a book. Via the system interface there will be some means of identifying the library member and book copy. So we can start with a library member object (theLibraryMember) and a certain Copy object (theCopy). The interaction begins by a BookBorrower actor sending a message to theLibraryMember. The message will specify the service required, in this case to borrow theCopy say, borrow(theCopy). This system has to check that it is permitted for the theLibraryMember to borrow another book: one of the duties of the library member will be to perform this check theLibraryMember sends itself a message, say, okToBorrow. Next we want to update the systems information about how many copies of the book are in the library, since now there is one fewer. This involves the book object (theBook) that is associated with theCopy. Suppose that theLibraryMember informs theCopy that it is being borrowed by sending it the message borrow, and that theCopy then sends theBook a message to say that a copy of the book is being borrowed, say borrowed. Nothing else needs to be done
theLibraryMember: LibraryMember
theCopy: Copy
theBook: Book