UML Overview Part 2 1 Behavioral Modeling m

UML Overview Part 2 1

Behavioral Modeling m Use Cases / Use Cases Diagrams m Interactions / Interaction Diagrams m State, Events, Actions /State Diagrams m Activity Diagrams 2

O-O World View An object-oriented system is regarded as a network of cooperating objects which – interact by sending each other messages maintain their own state – have an individual identity – 3

Object-Oriented Computation Model system operation control flow #1 draw #2 insert print Attributes #1 remove update Attributes #4 #3 insert #4 clear Attributes #2 remove data flow Attributes #3 draw-line 4

Interaction • Set of Messages exchanged among a set of Objects within a context to accomplish a purpose. • Used to model dynamic aspects of a system • Used to model flow of control within: m the overall system m a use case (represents a scenario) m a component m a class m an operation 5

Interaction (cont. ) • Used with two different focus: m m how messages are dispatched over time - focus is on time sequences of the message, i. e. what happens when. how messages are dispatched among objects - focus is on objects relationship, i. e, what happens and how it happens 6

Messages • One-way communication between two objects • Flow of control with information passed from the sender to the receiver. • May have parameters that convey values • Can be m a signal m a call m a return m create m destroy 7

Interaction Time Focus Example op 1() obj 1: Class 1 obj 2: Class 2 obj 3: Class 3 op 2() Object Time op 3() Object Activation (focus of control) Message 8

Interaction Objects Focus Example obj 1: Class 1 dothis(x) 1: dothat(x) 1. 1: dothat(x) : Class 3 Object obj 2: Class 2 Message Link 9

Interaction Diagrams • Two of the 9 diagrams of UML m Name m Graphical contents • Contain Objects, Links and Messages • Two main Types: m m Sequence Diagram: Collaboration Diagram: Emphasizes structural organization • These are semantically equivalent m both derived from same underlying model m each render some things the other does not 10

Sequence Diagram • Gives clear visual cues to the flow of control over time • Emphasizes time ordering • Shows object lifeline • Shows the focus of control 11

Collaboration Diagram • Gives clear visual cues to the flow of control in the context of the structural organizationof objects that collaborate • Emphasizes Path • Shows sequence number to indicate time order of messages • Can show iteration and branching 12

Collaboration Diagram request(order, customer) : Order. Taker 1: check. Credit(customer) 2: cost: =reserve(order) : Ticke. DB 3: debit(customer, cost) : Credit. Bureau 13

Modeling Flows of Control • Set the context for the interaction (system, subsystem, operation, class, scenario of UC) • Identify which objects play a role in the interaction • Place most important object in the center • Specify links among objects • Starting with message that initiates interaction, attach each subsequent messsage to the appropriate link. • Set the sequence number • If more formality is needed, add pre and post conditions to each message 14

Hints and Tips • Single sequence diagram show only one flow of control • Contains only those elements essential to undertanding one aspect • Name should help understand its purpose • Minimize Line Crossings 15
- Slides: 15