- Systems have static &dynamic characteristics
- Describes the internal behaviors of a system that supports the business processes -> dynamic view of the system
-One of the primary purposes of behavioral models is to show how the underlying objects in the problem domain will collaborate to support each use case.
- -Where as structural models represents the objects and relationships between objects, behavioral models depict the internal view of the business process that a use
- case describes.
-Modeling focus is at the object level.
Systems have static &dynamic characteristics
· Structural models describe the static aspects of the system
· Behavioral models describe the dynamics and interactions of the system’s components; show how the classes described in the structural models interact.
Key UML behavioral models
- ·Interaction diagrams:
- sequence diagram, communication diagram
· State Machines
- An interaction is a behavior that comprises a set of messages exchanged among a set of objects within a context to accomplish a purpose.
- Interaction diagrams show those interactions between objects including the messages that may be dispatched among them
- You model the dynamic aspects of a system using interaction diagram.
You model the dynamic aspects of a system using interaction diagram
- · To model the flow of control within an operation, an object, a component, a use case, or the system as a
· To visualize, specify, construct, and document the dynamics of a particular set of objects.
Interaction Diagram Components
- Two types of interaction diagrams in UML
Behaviors of an object
· A message is information sent to an object to tell the object to execute one of its behaviors (function or procedure). A message is a specification of a communication between objects
· Involves the invocation of an operation or the sending of a signal. Essentially a message is a function or procedure call from one object to another.
· When you pass a message, the result is an action.
When you pass a message, the
result is an action.
i) Call – invokes an operation on an object
ii) Parameter - specifies the data that must be supplied to an object to carry out a specific operation
iii) Return – returns a value to the caller
Two types of interaction diagrams in UML
- · Sequence diagram
- · Communication diagram
- Illustrate the objects that participate in a use-case and the messages that pass between objects over time for a particular use-case
- A sequence diagram is a dynamic model that shows the explicit sequence of messages that are passed between objects in defined interaction.
- When an object passes a message to another, the receiving objects might in turn send a message to another object. This stream of messages forms a sequence.
- A sequence diagram emphasizes the time ordering of messages.
Sequence Diagram Syntax
-A frame indicates the context of the sequence diagram.
Actor and Object
· Actors and objects that participate in a sequence by sending and/or receiving messages
· Actors and objects are placed across the top of the diagram using actor and object symbol.
It shows the life of an object during a sequence. It is a vertical dashed line that represents the existence of an object over a period of time.
- · It is a long, narrow rectangle placed onto a lifeline. It shows the period of time during which an object is performing an action either directly or through a subordinate
· A thin rectangular box is overlaid onto the lifeline to show when the objects are sending and receiving messages.
An X is placed at the end of the object’s lifeline to show that it is going out of existence.
· Conveys information from one object to another one
· Call messages are shown using solid lines connecting two objects with an arrow on the line showing which way the message is being passed
· Return message is depicted as a dashed line with an arrow on the end of the line portraying the direction of the return.
Drawing Sequence Diagram
Step 1: Determine the context of the sequence diagram
Step 2: Identify which objects will participate
Step 3: Set the lifeline for each object
Step 4: Layout the messages from the top to the bottom of the diagram based on the order in which they are sent
Step 5: Add the execution occurrence to each object’s lifeline
Step 6: Validate the sequence diagram
object diagram that shows message passing relationships
emphasize the flow of messages among objects, rather than timing and ordering of messages
Displays object interactions organized around objects and their links to one another
if you are interested in understanding the flow of control over a set of collaborating objects, you should use communication diagram
Communication Diagram Syntax
- Actor: a person or system that uses the system; external to the system
- An object: participates in a sequence by sending and /or receiving message
- An association: shows an association between actors and/or objects
- A message: conveys information form one object to another one
- Two features that distinguish them from sequence diagrams
Two features that distinguish them from sequence diagrams
- · Path -> to indicate how one object is linked to
· Sequence number -> to indicate the time order of a message
Building a Communication Diagram
- Determine the context of the Communication diagram
- Identify the participating objects and their associations. Place objects that participate in the interaction as the vertices in a graph
- Layout objects and associations. Render the links that connect these objects as the arcs of this graph
- Add messages. Adorn these links with the messages that objects send and receive
- Validate the sequence diagram
State Machine Diagrams
- State Machine -> A dynamic model that shows the different states through which a single object passes during its life in response to events, along with its responses and actions
- shows the different states of the object and what events cause the object to change from one state to another
- Typically not used for all objects -> Just for complex ones
- Used to understand the dynamic aspects of a single class and how its instances evolve over time
Components of State Machine Daigram
- Initial state and final state
Values of an object’s attributes at a point in time
· Change the values of the object’s attributes
· Something that takes place at a certain point in time and changes a value that describes an object which changes an object’s state
· Movement of an object from one state to another
· Some transition can have a guard condition which is Boolean expression that includes attribute values, which allows a transition to occur only if the condition is true
· A line with an arrow
Building State Machines
- Set the context
- Identify the initial final, and stable states of the object
- Determine the order in which the object will pass through stable states
- Identify the events, actions, and guard conditions associated with the transitions
- Validate the State Machine