Object-Oriented Analysis and Design: Unit-Ic Dynamic Modeling
Object-Oriented Analysis and Design: Unit-Ic Dynamic Modeling
Introduction
We examine changes to the objects and their relationships over time. Those aspects of a system with time and changes are called dynamic model Control is the aspect of the system that describes the sequences of operations that occur in response to external stimuli , without consideration of:
What the operation do What they operate on How they are implemented
L.GOWRI,CA
L.GOWRI,CA
Events
An event is something that happens at appoint in time. An event has no duration.
One event may logically precede or follow another, or the two events may be unrelated.
Two events that are casually unrelated are said to be concurrent; they have no effect on each other. Concurrent events can occur in any order. An event is a one way transmission of information from one object to another. Every event is a unique occurrence but we group them into event classes and give each event class a name to indicate common structure and behavior.
L.GOWRI,CA 4
8/20/2012
Event classes
An event conveys information from one object to another (either signals or data values) The data values conveyed by events are its attributes, like data values held by its objects. Attributes are shown in the parentheses after the event class name. Events include error conditions as well as normal occurrences. Eg :-transaction aborted , time out
L.GOWRI,CA 5
Event classes
L.GOWRI,CA
Scenarios
A scenario is a sequence of events that occurs during one particular execution of system. The scope of a scenario can vary It may include all events in the system or it may include only certain events Each event transmits information from one object to another Ex: dial tone begins transmits a signal from the phone line to the caller
L.GOWRI,CA 7
L.GOWRI,CA
8/20/2012
Event Trace
After writing a scenario is to identify the sender and receiver objects of each end The sequence of events and the objects exchanging events can both be shown in an augmented scenario called an event trace diagram This diagram shows each object as a vertical line and each event as a horizontal arrow from the sender object to the receiver object
L.GOWRI,CA 9
Event Trace
L.GOWRI,CA
10
States
A states is an abstraction of the attribute values and links of an object State has duration . It occupies an interval of time State is often associated with a continuous activity. Ex. Telephone ringing A state separates two events and event separates two states
L.GOWRI,CA 11
L.GOWRI,CA
8/20/2012
State Diagrams
A state diagram relates events and states When an event is received, the next state depends on the current state as well as the event A change of state caused by an event is called transitions A state diagram is a graph whose nodes are states and whose directed arcs are transitions labeled by and event names
L.GOWRI,CA 13
State Diagrams
A state is drawn as a rounded box containing an optional name A transition is drawn as a arrow from the receiving state to the target state The label on the arrow is the name of the event causing the transition State diagram specifies the state sequence caused by an event sequence. A sequence of events corresponds to a path through the graph
L.GOWRI,CA 14
State Diagrams
If an object is in a state and an event labeling one of its transition occurs, the objects enters the state on the target end of the transition. The transition is said to fire.
If more than one transition leaves a state then the first event to occur causes the corresponding transition to fire. If an event occurs that no transition leaving the current state, then the event is ignored.
State diagram contains sequences associated with normal call as well as abnormal call ( time out while dialing , getting busy line) States can represent
continuous loops one shot life cycles or
L.GOWRI,CA 15 L.GOWRI,CA 16
8/20/2012
L.GOWRI,CA
18
Conditions
A condition is a Boolean function of object values It is valid over interval of time A state can be defined in terms of a condition Conditions can be used as guards on transitions A guards transitions fires when its event occurs , but only if the guard condition is true A condition is listed within square brackets [] after an event name
L.GOWRI,CA 19
Conditions
For example
a person goes out in the morning (event), if the temperature is below freezing (condition) , then put on your gloves(next state).
L.GOWRI,CA
20
8/20/2012
Conditions
Operations
It shows how events trigger operations There are two types
Activity Action
L.GOWRI,CA
21
L.GOWRI,CA
22
Activity
An activity is an operation that takes time to complete. An activity is associated with a state. Activities include continuous as well as sequential events. A state may control a continuous activity that persists until an event terminates it by calling a transition from the state. Notation : do: activity name within state box
It indicates that activity starts an entry to the state and stops on exit.
Activity
event name
If an event causes a transition from the state before the activity is complete, it terminates prematurely.
L.GOWRI,CA 23 L.GOWRI,CA 24
8/20/2012
Actions
An action is an instantaneous operation. It is associated with an event Actions can also represent internal control operations, such as setting attributes or generating other events. Notation : (/ on transition) for action and the name (or) description of the action following the name of the event.
L.GOWRI,CA 25
Actions
right button down/display pop up menu idel right button up/erase pop up menu Menu visible
Cursor moved/highlight menu item
L.GOWRI,CA
26
Actions
Activity
Difference between
Action
1. can be performed within a state. 2. can be continuous. 3. can be sequential. 4. takes time.
1. can be performed within a state or during a transition. 2. can not be interrupted. 3. is atomic. 4. May be take time.
L.GOWRI,CA
27
L.GOWRI,CA
28
8/20/2012
State diagrams
Disadvantages
Quite complex when no of states is increase Difficult to specify concurrency
Idle
off hook
on hook time out Time out time out invalid number Recorded valid number
message
do: play message
on hook
Dial tone
do: sound dial tone
digit (n)
digit (n)
Dialing
Busy tone
do: sound busy tone
busy
Connecting
routed
message done
called phone answers / connect line called phone hangs up / disconnect line
L.GOWRI,CA 30
8/20/2012
L.GOWRI,CA
33
L.GOWRI,CA
34
Events can also be expanded into subordinate state diagrams The following figure shows the select item event from Fig - i
L.GOWRI,CA
36
8/20/2012
State generalization
States may have sub states that inherit the transitions of their super states A super state is drawn as a large rounded box enclosing all of its sub states Sub states in turn can enclose further sub states The rounded boxes representing various states are nested, and called as contours
Event Generalization
Events can be organized into generalization hierarchy with inheritance of event attributes. An event hierarchy permits different levels of abstraction to be used at different places in a model.
L.GOWRI,CA
37
L.GOWRI,CA
38
Concurrency
1. Aggregation Concurrency A dynamic model describes a set of concurrent objects. A state of an entire system cant be represented by a single state in a single object. It is the product of the states of all objects in it. A state diagram for an assembly is a collection of state diagram, one for each component. By using aggregation we can represent concurrency. Aggregate state corresponds to combined state of all component diagrams.
L.GOWRI,CA 39 L.GOWRI,CA 40
10
8/20/2012
Concurrency
2. Concurrency within an object Concurrency within a single composite state of an object is shown by partitioning the composite state into sub diagrams with dotted lines.
Payment authorization
L.GOWRI,CA
41
L.GOWRI,CA
42
L.GOWRI,CA
11
8/20/2012
Actions on transitions
opening depress/motor up Door open/motor off depress/motor up closed open
depress/motor down
L.GOWRI,CA
45
L.GOWRI,CA
46
Internal actions
An event can cause an action to be performed without causing a state change The event name is written inside the state box, followed by a / and the name of the action Keywords entry, exit, and do are reserved words within the state box Self transition causes the exit and entry actions for the state to be executed Therefore there is a difference between an internal action and self transition
State
depress Open
entry/motor off
depress
L.GOWRI,CA
12
8/20/2012
Automatic transition
A state performs a sequential activity. An arrow without an event name indicates an automatic transition that fires when the activity associates with the source state is completed. If there is no activity, the unlabeled transitions fires as soon as the state is entered. Such transitions are called as lambda transitions.
L.GOWRI,CA 49
Sending events
An object can perform action of sending an event to another object. A system interacts by events. An event can be directed to a single or a group of objects. If a state can accept events from more than one object, the order in which concurrent events are received may affect final state. This is called a race condition (two events being received simultaneously ) Unwanted race conditions should be avoided.
L.GOWRI,CA 50
Object class
L.GOWRI,CA
51
L.GOWRI,CA
52
13