Title: Use Cases and Object Interaction
1Use Cases andObject Interaction
2Depicting System Behavior
- First, identify the use cases
- Use case typical interaction between a user and
the system - Use Case Diagram
- Depicts all use cases for a system
- Interaction Diagram
- Depicts a single use case as a collection of
interacting objects
3ExampleUse Case Diagram
LIBRARY SYSTEM
Facilitate Checkout
Search for Book
Borrower
Librarian
Facilitate Return
4Use Case Diagram Notation
- Stick Figures Actors
- Could be a human user or a subsystem
- Ellipses - Use Cases
- Links - between actors and use cases
- Links between use cases
- ltltusesgtgt to depict inclusion of a use case
- ltltextendsgtgt to depict variations of a general
use case
5Example ltltusesgtgt
Facilitate Checkout
ltltusesgtgt
Log-in
Librarian
ltltusesgtgt
Facilitate Return
Note UML v.1.3 uses ltltincludesgtgt instead of
ltltusesgtgt
6Example ltltextendsgtgt
By Author
ltltextendsgtgt
Search for Book query
Borrower
ltltextendsgtgt
By Subject
Note query is called an extension point
7Describing a Use Case
- Narrative
- Library example (Facilitate Checkout) Given a
borrowers ID Card and the book to be borrowed,
the librarian enters the borrowers ID number and
the books catalogue number. If the borrower is
allowed to check out the book, the system
displays that the book has been recorded as
borrowed - Or, an Interaction Diagram
8ExampleInteraction Diagram
2 checkIfAvailable()
Checkout Screen
Book
1 checkIfDelinquent() 3 borrowBook()
4 setBorrower()
Borrower
9Interaction (Collaboration) Diagram Notation
- Rectangles Classes/Objects
- Arrows Messages/Method Calls
- Labels on Arrows
- sequence number (whole numbers or X.X.X notation)
- method name (the message passed)
- more details, if helpful and necessary
(iterators, conditions, parameters, types, return
types)
10Methods
- Interaction Diagrams suggest/imply methods for
classes - Has consequences on detailed class diagram
- The label(s) of an arrow should be a method of
the class the arrow points to - Library System
- Borrower class should have at least two methods
(checkIfDelinquent and borrowBook)
11Including Conditionsand Types
2 avail checkIfAvailable()boolean
Checkout Screen
bBook
1 delinq checkIfDelinquent()boolean 3!delinq
avail borrowBook(Book b)
rBorrower
12Creating an Object
- new means a constructor is being called
- Implies object creation
1 addCustomer(custdetails)
CustomerList
Encoder
2 new
Note this means theaddCustomer method
willcontain code that createsa Customer object
Customer
13Iteration
- is an iterator
- means the method is called repeatedly
1 printSalesSummary()
Store
Manager
2 getTotalSales()
Note Store needs data from all branches to
produce a summary
Branch
14Summary
- Provide a Use Case Diagram to depict the use
cases of a system - For each use case, describe and provide an
Interaction Diagram - Depict use case as a collection of interacting
objects - Other diagramming techniques that aid in building
a dynamic model - State diagram describes object state changes
- Activity diagram describes method behavior