COP 4331 OODP Lecture 8 Object Concepts UML
COP 4331 – OOD&P Lecture 8 Object Concepts
UML – Intro. Case Study • Problem: Develop a computer system for a university library. The library currently uses a 1960’s program, written in an obsolete language for some simple bookkeeping tasks and a card index for user browsing. You are to build an interactive system which handles both of these aspects online
Case Study: Clarifying Requirements • Books and Journals – May have several copies of a book – Some books for short-term loan only – Other books 3 week loan – Only staff can borrow journals – Members can borrow up to 6 books – Staff can borrow up to 12 items – Items can be added or removed – Journals are bound at end of year
Case Study: Clarifying Requirements. 2 • Borrowing – Must keep track of when items are borrowed, due, and returned – Reminders for overdue items – In future borrowers my extend load in book is not reserved • Browsing – Anyone can search for book by title, author, etc – Check if book is available – Reserve book
Case Study: Use Case Model • Identify the tasks performed by each user of the system – User is called an actor in UML • Actor can also be an external system – Task is called a use case – Must analyze each use case in detail
Case Study: Use case • Borrow copy of book A Book. Borrower presents a book. The system checks that the potential borrower is a member of the library and that s/he does not already have the maximum permitted number of items on loan. (6 for member, 12 for staff) If the check succeeds, the system records that the member has this copy of the book on loan. Otherwise it refuses the loan.
Use Case Diagram, fig 3. 1
Case Study: Initial Simplification
Case Study: Identifying Classes • Consider nouns and noun phrases in problem description – Things in system include candidate classe
Candidate Classes Books and Journals: The library contains books and journals. There may be several copies of a book. Some books for shortterm loan only. All other books are for 3 week loan. Only a member of the staff can borrow journals. Library members can borrow up to 6 books at a time. Staff can borrow up to 12 items.
Candidate Classes. 2 Borrowing: The system must keep track of when books and journals are borrowed and returned, enforcing the rules described above.
Candidate Classes. 3 • Filter list, remove bad classes – Library: out of scope of our system – Short-term loan: loan is really an event – Week: measure of time – Item: vague – Time: outside scope of system – System: from metalanguage of description – Rule: from metalanguage
Candidate Classes. 4 • This leaves – Book – Journal – Copy (of book) – Library member – Member of staff
Candidate Classes. 5 • Library member and Staff member are users of the system – Users do not always occur inside the system – Unless their identity or other data about them needs to be retained
Relations Between Classes • Identify and name associations between classes – Names indicate relationship or interaction – Reveals multiplicity • Helps clarify understanding of system • Provides visualization of coupling
Initial Class Diagram, fig. 3. 4
Revised Class Diagram, fig. 3. 5
Interaction Daigrams • Show interactions between actors and objects in the system over time • Usually based on a use case or portion of one
Interaction Diagram, fig. 3. 6
Changes in State: State Diagram, fig 3. 7
- Slides: 20