Behavioral Modeling ISTM 201 Courtesy to Dr.Dasgupta 1 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports business processes in an organization Key UML behavioral models are: sequence diagrams, collaboration diagrams, and statechart diagrams 2 Objectives ■ Understand the rules and style guidelines for sequence and communication diagrams and behavioral state machines. ■ Understand the processes used to create sequence and communication diagrams and behavioral state machines. ■ Be able to create sequence and communication diagrams and behavioral state machines. ■ Understand the relationship between the behavioral models and the structural and functional models. 3 Purpose of Behavioral Models Show how objects colaborate to support each use case in the structural model Depict the internal view of the business process To show the effects of varied processes on the system 4 SEQUENCE DIAGRAM 5 Sequence Diagram Concepts Illustrates the classes that participate in a use case Shows the messages that pass between classes over time for one use case Can be a generic sequence diagram, but more frequently one is drawn for a single scenario within the use case Design diagrams are implementation specific -- database objects or specific GUI components serve as classes 6 Sequence Diagram 7 Steps in Creating a Sequence Diagram 1. Identify classes 2. Add messages 3. Place lifeline and focus of control 8 Syntax for Sequence Diagram 9 Steps of the Customer Places Order Scenario 10 Use Diagram for CD Selections Internet Sales System 11 Sequence Diagram for Customer Places Order Scenario 12 COLLABORATION DIAGRAM 13 Collaboration Diagrams Essentially an object diagram that shows message passing relationships instead of aggregation or generalization associations. Emphasize the flow of messages among objects, rather than timing and ordering of messages 14 Syntax for Collaboration Diagrams Actor Object Association Message Frame 15 Example Collaboration Diagram 16 Example: CD Selection 17 Collaboration Diagrams 1. Set the context. 2. Identify which objects (actors) and the associations between the objects participate in the collaboration. 3. Layout the communication diagram. 4. Add messages. 5. Validate the communication diagram. 18 Building a Collaboration Diagram Determine the context of the collaboration diagram Identify the participating objects and their associations Layout objects and associations Add messages Validate the sequence diagram 19 STATECHART DIAGRAM (also called Behavioral State Machine) 20 Statechart Concepts A dynamic model showing changes of state of a single class over time in response to events along with its responses and actions Typically not used for all classes, but just to help simplify the design of algorithms for methods of complex classes 21 Syntax for Statechart Diagram 22 Statechart Diagram for a Hospital Patient 23 Steps for Creating a Statechart Diagram 1. Identify the states 2. Identify the transitions 24 The Life of an Order 25 Statechart Diagram for an Order 26