0% found this document useful (0 votes)
12 views53 pages

C5 - Behavioral Modeling - Nogd

Uploaded by

Bùi Quang Giàu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views53 pages

C5 - Behavioral Modeling - Nogd

Uploaded by

Bùi Quang Giàu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

UNIVERSITY OF INFORMATION TECHNOLOGY

Faculty of Information Systems

Chapter 5

BEHAVIORAL MODELING

Dr. Cao Thi Nhan


LEARNING OBJECTIVES

1. Understand basic rules and guidelines for Sequence


diagram and State machine.

2. Have ability to create Sequence diagrams, and State


machines.

2
CONTENTS
1. Introduction
2. Sequence Diagrams
1. Elements of a Sequence Diagram
2. Guidelines for Creating Sequence Diagrams
3. State Machines
1. States, Events, Transitions, Actions, and Activities
2. Elements of a State machine
3. Creating a State machine
INTRODUCTION
INTRODUCTION
A behavioral model describes the internal dynamic
aspects of an information system that supports the
business processes
Purpose of behavioral models is to show how the
underlying objects will work together to form a
collaboration to support each of the use cases.
UML diagrams are used in behavioral modeling:
sequence diagrams, communication diagrams, and
(behavioral) state machines
Sequence Diagrams
Sequence Diagrams
1. Introduction
2. Elements of a Sequence Diagram
3. Guidelines for Creating Sequence Diagrams
Sequence Diagrams
Introduction
 Sequence diagram shows the objects that participate
in a use case and the messages that pass between
them over time for one use case
 It can be a generic sequence diagram that shows all
possible scenarios for a use case
 Usually analyst develops a set of instance sequence
diagrams, each of which depicts a single scenario
within the use case.
 The design diagrams are very implementation
specific, often including database objects or specific
user interface components as the objects.
Sequence Diagrams
Sequence Diagrams
Sequence Diagrams
Elements of a Sequence Diagram
1. An actor
2. An object
3. A Lifeline
4. An execution occurrence
5. A Message
6. A guard condition
7. For object destruction
8. A frame
Sequence Diagrams
Elements of a Sequence Diagram
1. An actor:
 Is a person or system that derives benefit from and is
external to the system.
 Participates in a sequence by sending and/or
receiving messages
Sequence Diagrams
Elements of a Sequence Diagram
2. An object:
 Participates in a sequence by sending and/or
receiving messages
Sequence Diagrams
Elements of a Sequence Diagram
3. A lifeline:
 The life of an object during a sequence
 Contains an X at the point at which the class no
longer interacts
Sequence Diagrams
Elements of a Sequence Diagram
4. An execution occurrence:
 Is a long narrow rectangle placed atop a lifeline
 Denotes when an object is sending or receiving
messages
Sequence Diagrams
Elements of a Sequence Diagram
4. An execution occurrence:
 Is a long narrow rectangle placed atop a lifeline
 Denotes when an object is sending or receiving
messages
Sequence Diagrams
Elements of a Sequence Diagram
5. A message:
 Conveys information from one object to another one
 An operation call is labeled with the message being
sent and a solid arrow, whereas a return is labeled
with the value being returned and shown as a dashed
arrow
Sequence Diagrams
Elements of a Sequence Diagram
5. A message:
 Conveys information from one object to another one
Sequence Diagrams
Elements of a Sequence Diagram
6. A guard condition:
 Represents a test that must be met for the message to
be sent
Sequence Diagrams
Elements of a Sequence Diagram
7. For object destruction:
 An X is placed at the end of an object’s lifeline to
show that it is going out of existence
Sequence Diagrams
Elements of a Sequence
Diagram
8. A frame:
 Indicates the context
of the sequence
diagram
Sequence Diagrams
Elements of a Sequence Diagram
1. An actor
2. An object
3. A Lifeline
4. An execution occurrence
5. A Message
6. A guard condition
7. For object destruction
8. A frame
Guidelines for Creating Sequence
Diagrams
Guidelines for Creating Sequence Diagrams

1. Set context: use-case scenario


2. Identify Actors and Objects: the actors and objects
that interact with each other during the use-case
scenario
3. Set Lifeline
4. Add Messages
5. Place Execution Occurrence
6. Validate
Sequence Diagram Example
Sequence Diagram Example

: RegisterForCoursesForm : RegistrationController ::CourseCatalogSystem : Schedule : Student


: Course Catalog
: Student

1. // create schedule( )
1.1. // get course offerings( )
Student wishes to
create a new 1.1.1. // get course offerings(forSemester)
schedule
1.1.1.1. // get course offerings( )

1.2. // display course offerings( )


A list of the available
course offerings for this
semester are displayed

A blank schedule
1.3. // display blank schedule( )
is displayed for the
students to select
offerings

2. // select 4 primary and 2 alternate offerings( )

2.1. // create schedule with offerings( )


2.1.1. // create with offerings( )

2.1.2. // add schedule(Schedule)

At this, point the Submit Schedule subflow is executed.


Sequence Diagram Example

: RegisterForCoursesForm : RegistrationController : Schedule : : CourseOffering : Student


: Student PrimaryScheduleOfferingInfob

1. // submit schedule( )

1.1. // submit schedule( )


1.1.1. // save( )

1.1.2. // submit( )
1.1.2.1. // is selected?( )

[ is selected ]
1.1.2.2. // has pre-requisites(CourseOffering)
Repeat for all primary
course offerings. 1.1.2.3. // still open?( )
An attempt is made
to register the 1.1.2.4. // any conflicts?( )
student for all
selected course
offerings [ has pre-requisites, course offering open,
and no schedule conflicts ]
1.1.2.5. // add student(Schedule)

1.1.2.6. // mark as enrolled in( )


Sequence Diagrams
1. Introduction
2. Elements of a Sequence Diagram
3. Guidelines for Creating Sequence Diagrams
CONTENTS
1. Introduction
2. Sequence Diagrams
1. Elements of a Sequence Diagram
2. Guidelines for Creating Sequence Diagrams
3. State Machines
1. States, Events, Transitions, Actions, and Activities
2. Elements of a State machine
3. Creating a State machine
State Machines
State Machines
1. Introduction
2. Elements of a State Machines
3. Guidelines for Creating State Machines
State Machines
Introduction
 A state machine shows the different states through
which a single object passes during its life.
 Typically, state machines are not used for all objects,
they are used with complex objects to help simplify
the design of algorithms for their methods
 The behavioral state machine shows the different
states of the object and what events cause the object
to change from one state to another
State Machines
Introduction
State Machines
Introduction
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
1. State
 Has a name that represents the state of an object
 Is shown as a rectangle with rounded corners.
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
2. An initial state, A final state
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
7. Frame: indicates the context of the State Machine
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
3. Event
 Is an occurrence that triggers a change in state
 Is used to label a transition
4. Transition
 Indicates that an object in the first state will enter the second
state
State Machines
Elements of a State Machines
1. States
2. An initial state, A final state
3. Events
4. Transitions
5. Actions
6. Activities
7. Frame
State Machines
Elements of a State Machines
5. Action
 Action cannot be interrupted
 It is associated with a transition
6. Activity
 Activity can be interrupted. Activities take a long period of
time to complete
 It can be started and stopped by an action.
State Machines
Elements of a State Machines

State Event

State Name event(args)


[guard condition]
stateVar : type = value / operation(args)
^target.sendEvent(args)
entry/ entry action
do/ activity
exit/ exit action Action

Activity
Transition
State Machines
Elements of a State Machines
State Machines
Scheduled Scheduled

[ Current date is less than 60 days before flight ] [ Current date is less than 60 days before flight ]
/ Set number of passenger to 0 / Set number of passenger to 0

Add / Remove passenger Adding passengers

Add passenger[ Last seat was sold ] Add / Remove passenger

Open Full Add passenger[ Last seat was sold ]

Open Full
Remove passenger( PassengerName )

[ 10 min before scheduled takeoff ] Remove passenger( PassengerName )


[ 10 min before scheduled takeoff ]
[ 10 min before scheduled takeoff ]

Closed Closed
State Machines
Creating a State Machines
1. Set context
2. Identify object states
3. Layout diagram
4. Add transition
5. Validate
State Machines
1. Introduction
2. Elements of a State Machines
3. Guidelines for Creating State Machines
Reference
1. Alan Dennis, Babara Haley Wixom, David Tegarden, Systems
Analysis and Design: An Object-Oriented Approach with UML,
5th Edition, Wiley, 2015.
2. Grady Booch, Robert A. Maksimchuk, Michael W. Engle, Bobbi
J. Young, Jim Conallen, Kelli A. Houston, Object-Oriented
Analysis and Design with Applications, 3rd Edition, Addison-
Wesley Professional, 2007.
3. System Analysis and Design slides, Faculty of Information
Systems, University of Information Technology, HCMC, 2018.
4. https://www.uml-diagrams.org/sequence-diagrams.html
State Machines

You might also like