Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Modeling behavior with Sequence diagrams

12.968 visualizaciones

Publicado el

Modeling software interaction and behavior with sequence diagrams

Publicado en: Educación, Tecnología
  • Sé el primero en comentar

Modeling behavior with Sequence diagrams

  1. 1. Session 5:Modeling Behavior with UML Sequence Diagrams<br />Analysis and Specification of Information Systems<br />Spring 2008<br />Eran Toch<br />http://www.technion.ac.il/~erant<br />
  2. 2. Outline<br />Introduction<br />Basic notation<br />Alternating paths<br />Modularity<br />
  3. 3. Modeling Process<br />Introduction | Basics | Alternations | Modularity<br />
  4. 4. Why to Model Behavior?<br />How do we use the SMS Server interface? What is the order of executing the operations?<br />sendMessage, getStatus, Resend?<br />getStatus, sendMessage, checkForMessages?<br />When do we use resend?<br />Introduction | Basics | Alternations | Modularity<br />
  5. 5. Behavioral Modeling<br />[if getStutus == err]<br />Send message<br />Resend<br />Resend<br />Get Status<br />Adds a new msg<br />Message queue<br />Introduction | Basics | Alternations | Modularity<br />
  6. 6. Outline<br />Introduction<br />Basic elements<br />Alternating paths<br />Modularity<br />
  7. 7. Building a Sequence Diagrams<br />Sequence diagrams capture the use-case behavior using the foundation of the classes. <br />Use Case 1<br />Class C<br />Class A<br />Use Case 3<br />Use Case 2<br />Class D<br />Class B<br />Objects<br />Sequence = <br />+<br />messages<br />Introduction | Basics | Alternations | Modularity<br />
  8. 8. Sequence Diagrams<br />A simple sequence diagram:<br />objects<br />sd Product Buying<br />Diagram Name<br />p : Product<br />: ShooppingCart<br />customer<br />display()<br />message<br />getPrice()<br />activation (focus of control) <br />addProduct (p)<br />checkout ()<br />Lifeline<br />Introduction | Basics | Alternations | Modularity<br />
  9. 9. Object Control<br />obj1 : Class1<br />Illustration<br />obj2 : Class2<br />obj1 : Class1<br />user<br />Object Creation<br />operate()<br />do (…)<br />create (…)<br />: Class3<br />Return Message<br />foo()<br />Messages to self<br />Object Destruction<br />Introduction | Basics | Alternations | Modularity<br />
  10. 10. Illustration<br />Corresponding Class Diagram<br />Notice that a dependency exists whenever messages are passed between instances of the class<br />Dependencies can be overridden by associations, aggregations etc.<br />Introduction | Basics | Alternations | Modularity<br />
  11. 11. Sequences and Use-Cases<br />p : Product<br />: ShooppingCart<br />customer<br />display()<br />getPrice()<br />addProduct (p)<br />checkout ()<br />create (…)<br />: Order<br />Hidden part<br />Visible part<br />Introduction | Basics | Alternations | Modularity<br />
  12. 12.
  13. 13. Full Message Attributes<br />sequence number<br />[sequence-expression]<br />[return-value :=] [message-name] [(argument-list)]<br />C3.1: res := getLocation (fig)<br />message name<br />argument list<br />return value<br />Introduction | Basics | Alternations | Modularity<br />
  14. 14. Different Kinds of Messages<br />Synchronous Message<br />asynchronousMessage<br />Return Message<br />Introduction | Basics | Alternations | Modularity<br />
  15. 15. Synchronous & Asynchronous Messages<br />Example<br />Example<br />Nested Flow<br />Asynchronous Flow<br />manager<br />sensor<br />eye<br />sensor<br />manager<br />alarm<br />check<br />unknown<br />unknown<br />ring<br />check<br />operate<br />log<br />Price need to be finished, before teller can do another operation (getName)<br />Ring is executed, while the control flow is returned to err handle and appl<br />Introduction | Basics | Alternations | Modularity<br />
  16. 16. Outline<br />Introduction<br />Basic elements<br />Alternating paths<br />Modularity<br />
  17. 17. Flow Constructs<br />If<br />Loop<br />Else<br />Repeat<br />Jump<br />When we tell a scenario, which types of alternatives do we need? <br />Introduction | Basics | Alternations | Modularity<br />
  18. 18. Options<br />Example<br />msg : Message<br />: Database<br />Fragment<br />opt<br />Condition<br />[msg.status=confirmed]<br />archive(msg)<br />Used for modeling simple optional blocks.<br />Has one operand; no &quot;else&quot; guard.<br />Do something...<br />Introduction | Basics | Alternations | Modularity<br />
  19. 19. Alternatives<br />msg : Message<br />: Database<br />: Admin<br />alt<br />Alternative Fragment group<br />[msg.status=confirmed]<br />archive(msg)<br />Condition<br />[msg.status=error]<br />notify(msg.getID())<br />[else]<br />Execution regions. At most one will execute.<br />wait()<br />Else condition<br />(optional)<br />Introduction | Basics | Alternations | Modularity<br />
  20. 20. Loops<br /> : OS<br />: Folder<br />: File<br />loop<br />[for each Folder]<br />Loop Fragment<br />Display()<br />loop<br />[for each File]<br />Condition<br />Display()<br />Nested Loop Fragment<br />Introduction | Basics | Alternations | Modularity<br />
  21. 21. Breaks<br /> : Policy<br /> : User<br />: User Manager<br />isLooged = login(name,pass)<br />If the condition is met, the break fragment is executed, and the reminder of the sequence is ignored<br />break<br />[¬isLooged]<br />addBadLogin(name)<br />Do something…<br />Handy in model exception handling<br />Do something …<br />Introduction | Basics | Alternations | Modularity<br />
  22. 22. Examples of Guards<br />[for each Object]<br />[5]<br />[i=1..5]<br />[status = okay]<br />No guard means an infinite loop<br />Introduction | Basics | Alternations | Modularity<br />
  23. 23. Outline<br />Introduction<br />Basic elements<br />Alternating paths<br />Modularity <br />
  24. 24. MODULARITY<br />We need ways to create modular scenarios<br />Introduction | Basics | Alternations | Modularity<br />
  25. 25. Referencing a diagram<br /> : Policy<br /> : User<br />: User Manager<br />login(name,pass)<br />ref<br />Login Handling(user,pass) :bool<br />Reference Gate<br />Do something…<br />Do something …<br />Introduction | Basics | Alternations | Modularity<br />
  26. 26. Referenced Diagram<br />sd Login Handling<br />Diagram name<br />: User Manager<br />: UserAccount<br />loop<br />Input message<br />login(name,pass)<br />[for each UserAccount]<br />cName -= getUseNamer()<br />cName -= getUseNamer()<br />Output message<br />opt<br />[cName = name]<br />isInSystem(true)<br />true<br />false<br />Introduction | Basics | Alternations | Modularity<br />
  27. 27. Summary<br /><ul><li>Behavior Modeling</li></ul>Sequence models interaction<br /><ul><li>Language</li></ul>Objects + lifeline<br />Messages<br /><ul><li>Alternations</li></ul>Loops<br />Alternatives<br /><ul><li>Modularity</li></ul>Referencing<br />Introduction | Basics | Alternations | Modularity<br />

×