1 / 38

Chapter 15

Chapter 15. UML Interaction Diagrams. What are Interaction Diagrams?. Illustrate how objects interact through messages Two types: Sequence Diagrams and Communication Diagrams. Example Code. Public class A { Private BB myB = new BB(); Public void doOne() { myB.doTwo(); myB.doThree();

Download Presentation

Chapter 15

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 15 UML Interaction Diagrams CS6359 Fall 2012 John Cole

  2. What are Interaction Diagrams? • Illustrate how objects interact through messages • Two types: Sequence Diagrams and Communication Diagrams CS6359 Fall 2012 John Cole

  3. Example Code Public class A { Private BB myB = new BB(); Public void doOne() { myB.doTwo(); myB.doThree(); } } CS6359 Fall 2012 John Cole

  4. Sequence Diagram A B CS6359 Fall 2012 John Cole

  5. Sequence Diagram CS6359 Fall 2012 John Cole

  6. Guideline • Spend time doing dynamic modeling with interaction diagrams, not just static object modeling with class diagrams • This makes you think about how things happen, not just the objects you need CS6359 Fall 2012 John Cole

  7. Sequence vs. Communication • UML tools usually emphasize sequence • Easier to see call flow sequence—read from top to bottom • Communication diagrams are more space-efficient • Communication Diagrams expand top to bottom; Sequence Diagrams expand left to right CS6359 Fall 2012 John Cole

  8. Common Notation CS6359 Fall 2012 John Cole

  9. Singleton Objects • Only one instance of the class instantiated at any time. CS6359 Fall 2012 John Cole

  10. Lifeline Boxes • Lifeline is a dashed (or solid, in UML 2) line below the object. CS6359 Fall 2012 John Cole

  11. Messages CS6359 Fall 2012 John Cole

  12. Focus of Control • The bar on the left is an Execution Specification bar. Indicates focus of control CS6359 Fall 2012 John Cole

  13. Reply or Returns • Use the message syntax returnVar=Message(parameter) • Using a reply or return message at the end of an activation bar CS6359 Fall 2012 John Cole

  14. Messages to Self • Message sent to itself with a nested activation bar CS6359 Fall 2012 John Cole

  15. Creation of Instances • Dashed line with filled arrow for synchronous message, open if async. Name “create” is not required; it’s a UML idiom CS6359 Fall 2012 John Cole

  16. Lifelines and Object Destruction • Show explicit destruction of an object, such a when a database connection is closed CS6359 Fall 2012 John Cole

  17. Diagram Frames • These support conditionals and looping CS6359 Fall 2012 John Cole

  18. Frame Operators CS6359 Fall 2012 John Cole

  19. Conditional Messages CS6359 Fall 2012 John Cole

  20. UML 1.x Conditionals CS6359 Fall 2012 John Cole

  21. Conditional If…Else CS6359 Fall 2012 John Cole

  22. Code to Iterate Over Collection public class Sale { private List<SalesLineItem> lineItems =new ArrayList<SalesLineItem>(); public Money getTotal() { Money total = new Money(); Money subtotal = null; for ( SalesLineItem lineItem : lineItems ){ subtotal = lineItem.getSubtotal(); total.add( subtotal ); } return total;} // . . } CS6359 Fall 2012 John Cole

  23. Implicit Iteration CS6359 Fall 2012 John Cole

  24. Nesting Frames CS6359 Fall 2012 John Cole

  25. Relating Interaction Diagrams • Interaction Occurrence (or Use) is a reference to an interaction within another interaction. CS6359 Fall 2012 John Cole

  26. Invoking Static Methods • Metaclasses or static classes are instances of themselves. Calling a static method uses the name of the class, not the name of the instance. CS6359 Fall 2012 John Cole

  27. Polymorphic Messages • Multiple sequence diagrams: One to the superclass, one to each case, each starting with a found polymorphic message (next slide) CS6359 Fall 2012 John Cole

  28. Polymorphic Messages CS6359 Fall 2012 John Cole

  29. Async and Sync Calls • Async (non-blocking) calls are a stick (unfilled) arrow, sync are a filled arrow • This can be used for multi-threading Public class ClockStarter { Public void startClock { Thread t = new Thread(new Clock)); t.start(); System.runFinalization(); // } } CS6359 Fall 2012 John Cole

  30. Async Calls CS6359 Fall 2012 John Cole

  31. Links • Connection path between objects. Navigation and visibility. Instance of an association. • Multiple messages and messages both ways CS6359 Fall 2012 John Cole

  32. Creation of Instances • Message named Create. If some other name is used, use the UML stereotype <<Create>> to indicate. Message can include parameters. • UML tagged value [new] to indicate creation CS6359 Fall 2012 John Cole

  33. Message Number Sequencing • If ordering is important, indicate this with sequence numbers. • The first message is not numbered • Order and nesting of subsequent numbers is shown with levels (next slide) CS6359 Fall 2012 John Cole

  34. Sequencing CS6359 Fall 2012 John Cole

  35. Conditional Messages • Show this with the condition in brackets CS6359 Fall 2012 John Cole

  36. Mutually Exclusive Conditionals • Equivalent of If…else. Modify the sequence expression with a letter: CS6359 Fall 2012 John Cole

  37. Iteration CS6359 Fall 2012 John Cole

  38. Iteration Over a Collection CS6359 Fall 2012 John Cole

More Related