Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interaction Diagrams CS 124. Object collaboration A use case carried out involves objects and interaction or collaboration between these objects Method.

Similar presentations


Presentation on theme: "Interaction Diagrams CS 124. Object collaboration A use case carried out involves objects and interaction or collaboration between these objects Method."— Presentation transcript:

1 Interaction Diagrams CS 124

2 Object collaboration A use case carried out involves objects and interaction or collaboration between these objects Method calls between objects This collaboration is depicted in the UML through an Interaction Diagram Two types: Collaboration diagram Sequence diagram

3 Example: Collaboration Diagram Checkout Screen :Borrower :Book 1: borrowAllowed() 3: borrowBook() 2: isAvailable() 4: setBorrower()

4 Interaction (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)

5 Methods 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)

6 Including object names, conditions and Types Checkout Screen r:Borrower b:Book 1: allow = borrowAllowed():boolean 3:[allow & avail] borrowBook(Book b) 2: avail = isAvailable():boolean 4: setBorrower( Book r )

7 Creating an Object new means a constructor is being called Implies object creation :Customer :CustomerList 1: addCustomer(custdetails) :Encoder 2: new Note: this means the addCustomer method will contain code that creates a Customer object

8 Iteration * is an iterator means the method is called repeatedly :Branch :Store 1: printSalesSummary() :Manager 2: * getTotalSales() Note: Store needs data from all branches to produce a summary

9 Sequence Diagram Variant of an interaction diagram that emphasizes sequence Objects shown as boxes on top of the diagram Dashed vertical line below the box: object’s lifeline Activation bar to indicate the object’s activation Sequence number unnecessary because top to bottom calling sequence is assumed Message notation the same as for collaboration diagrams

10 Sequence Diagram Checkout Screen :Borrower:Book borrowAllowed() isAvailable() setBorrower() borrowBook()

11 Collaboration versus Sequence Diagrams Use collaboration diagrams when you want to make use of a two-dimensional layout of interacting objects Ok when there aren’t that many objects Use sequence diagrams when layout doesn’t help in presentation and when you want to clarify calling sequence


Download ppt "Interaction Diagrams CS 124. Object collaboration A use case carried out involves objects and interaction or collaboration between these objects Method."

Similar presentations


Ads by Google