www.techstudent.co.cc state modeling. events an event is an occurrence at a point in time, such as...

45
www.techstudent.co.cc www.techstudent.co.cc State Modeling State Modeling

Upload: jasmine-warren

Post on 21-Jan-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

State ModelingState Modeling

Page 2: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

EventsEvents

An event is an occurrence at a point in time, such An event is an occurrence at a point in time, such as user depresses left button or flight 123 departs as user depresses left button or flight 123 departs from Chicago. By definition, an event happens from Chicago. By definition, an event happens instantaneously with regard to the time scale of an instantaneously with regard to the time scale of an application. One event may logically precede or application. One event may logically precede or follow another or two events may be unrelated. follow another or two events may be unrelated.

A signal is an explicit one-way transmission of A signal is an explicit one-way transmission of information from one object to another. It is information from one object to another. It is different from a subroutine call that returns a value. different from a subroutine call that returns a value. A signal event is the event of sending or receiving a A signal event is the event of sending or receiving a signal. A change event is an event that is caused by signal. A change event is an event that is caused by satisfaction of boolean expression.satisfaction of boolean expression.

Page 3: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

StatesStates

A state is an abstraction of the values and links of A state is an abstraction of the values and links of an object. Sets of values and links are grouped an object. Sets of values and links are grouped together into a state according to the gross together into a state according to the gross behavior of objects.behavior of objects.

Events and States Events and States

Page 4: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Transitions and ConditionsTransitions and Conditions

A transition is an instantaneous change from one state to A transition is an instantaneous change from one state to another. The transition is said to fire the change from the another. The transition is said to fire the change from the source state to the target state. The origin and target of a source state to the target state. The origin and target of a transition usually are different states, but may be same. A transition usually are different states, but may be same. A transition fires when its event occurs. The choice of next transition fires when its event occurs. The choice of next state depends on both the original state and the event state depends on both the original state and the event received. An event may cause multiple objects to received. An event may cause multiple objects to transitions.transitions.

A guard condition is a boolean expression that must be true A guard condition is a boolean expression that must be true in order for a transition to occur. A guard condition fire when in order for a transition to occur. A guard condition fire when its event occurs, but only if the guard condition is true. its event occurs, but only if the guard condition is true. ““when you wake up in the morning (event), if the when you wake up in the morning (event), if the temperature is below freezing (condition), then put on your temperature is below freezing (condition), then put on your gloves ( next state)gloves ( next state)

Page 5: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

State DiagramsState Diagrams

A State diagram is a graph whose nodes are states A State diagram is a graph whose nodes are states and whose directed arcs are transitions between and whose directed arcs are transitions between states. A state diagram specifies the state states. A state diagram specifies the state sequence caused by event sequences. State names sequence caused by event sequences. State names must be unique within the scope of a state must be unique within the scope of a state diagram. All objects in a class execute the state diagram. All objects in a class execute the state diagram for that class, which models their behavior. diagram for that class, which models their behavior. The state diagram consists of multiple diagrams, The state diagram consists of multiple diagrams, one state diagram for each class with important one state diagram for each class with important temporal behavior. A state diagram must match temporal behavior. A state diagram must match their interface-events and guard conditions. their interface-events and guard conditions.

Page 6: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

State DiagramsState Diagrams

State diagrams are used to describe the State diagrams are used to describe the behavior of a system.  State diagrams behavior of a system.  State diagrams describe all of the possible states of an object describe all of the possible states of an object as events occur. as events occur. 

Each diagram usually represents objects of a Each diagram usually represents objects of a single class and track the different states of single class and track the different states of its objects through the system its objects through the system

State diagram for a class shows the states State diagram for a class shows the states that objects of that class may assume and the that objects of that class may assume and the transitions the objects may make from state.transitions the objects may make from state.

Page 7: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Basic State DiagramsBasic State Diagrams

State diagrams have very few elements.  The basic elements are rounded boxes representing State diagrams have very few elements.  The basic elements are rounded boxes representing the state of the object and arrows indicting the transition to the next state.  The activity section the state of the object and arrows indicting the transition to the next state.  The activity section of the state symbol depicts what activities the object will be doing while it is in that stateof the state symbol depicts what activities the object will be doing while it is in that state

Page 8: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Basic State DiagramsBasic State Diagrams

All state diagrams being with an initial state of the object.  This is the state of the object when All state diagrams being with an initial state of the object.  This is the state of the object when it is created.  After the initial state the object begins changing states.  Conditions based on the it is created.  After the initial state the object begins changing states.  Conditions based on the activities can determine what the next state the object transitions to. activities can determine what the next state the object transitions to.

Page 9: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Basic State DiagramsBasic State Diagrams

An ExampleAn Example

Page 10: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.ccState Diagram for a telephone line

Page 11: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Nested State DiagramsNested State Diagrams

State diagrams can also show a super-state State diagrams can also show a super-state for the object. A super-state is used when for the object. A super-state is used when many transitions lead to the a certain state.  many transitions lead to the a certain state.  Instead of showing all of the transitions from Instead of showing all of the transitions from each state to the redundant state a super-each state to the redundant state a super-state can be used to show that all of the state can be used to show that all of the states inside of the super-state can states inside of the super-state can transition to the redundant state.  This helps transition to the redundant state.  This helps make the state diagram easier to read make the state diagram easier to read

Page 12: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Nested State DiagramsNested State Diagrams

Both the Checking and Dispatching states can transition into the Canceled state, so a transition is shown  Both the Checking and Dispatching states can transition into the Canceled state, so a transition is shown  from a super-state named Active to the state Cancel.  By contrast, the state Dispatching can only transition from a super-state named Active to the state Cancel.  By contrast, the state Dispatching can only transition to the Delivered state, so we show an arrow only from the Dispatching state to the Delivered state to the Delivered state, so we show an arrow only from the Dispatching state to the Delivered state

Page 13: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Nested State DiagramsNested State Diagrams

A State of Washing MachineA State of Washing Machine

Page 14: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrent States and SynchronizationConcurrent States and Synchronization

This covers the concurrent states that an object may This covers the concurrent states that an object may have and goes deeper into the topic of nested states. have and goes deeper into the topic of nested states. Activity diagrams describe the workflow behavior of a Activity diagrams describe the workflow behavior of a system.  system. 

Activity diagrams are similar to state diagrams, Activity diagrams are similar to state diagrams, because activities are the state of doing something.  because activities are the state of doing something.  The diagrams describe the state of activities by The diagrams describe the state of activities by showing the sequence of activities performed.  Activity showing the sequence of activities performed.  Activity diagrams can show activities that are conditional or diagrams can show activities that are conditional or parallel. parallel.

Activity diagrams should be used in conjunction with Activity diagrams should be used in conjunction with other modeling techniques such as interaction other modeling techniques such as interaction diagrams and state diagrams.diagrams and state diagrams.

Page 15: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrent States and SynchronizationConcurrent States and Synchronization

This covers the concurrent states that an object This covers the concurrent states that an object may have and goes deeper into the topic of may have and goes deeper into the topic of nested states. Activity diagrams describe the nested states. Activity diagrams describe the workflow behavior of a system.  workflow behavior of a system. 

                                                         1

Page 16: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrent States and SynchronizationConcurrent States and Synchronization

Page 17: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrent States and SynchronizationConcurrent States and Synchronization

The diagram shows the flow of actions in the system's workflow.  Once the order is received the activities The diagram shows the flow of actions in the system's workflow.  Once the order is received the activities split into two parallel sets of activities.  One side fills and sends the order while the other handles the split into two parallel sets of activities.  One side fills and sends the order while the other handles the billing.  On the Fill Order side, the method of delivery is decided conditionally.  Depending on the condition billing.  On the Fill Order side, the method of delivery is decided conditionally.  Depending on the condition either the Overnight Delivery activity or the Regular Delivery activity is performed.  Finally the parallel either the Overnight Delivery activity or the Regular Delivery activity is performed.  Finally the parallel activities combine to close the order activities combine to close the order

Page 18: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrent States and SynchronizationConcurrent States and Synchronization

Example: Washing MachineExample: Washing Machine

Page 19: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Concurrency Concurrency

The state model implicitly supports concurrency among objects, In general, objects are autonomous entities that can act and change The state model implicitly supports concurrency among objects, In general, objects are autonomous entities that can act and change state independent of one another. Objects need not be completely independent and may be subject to shared constraints that cause state independent of one another. Objects need not be completely independent and may be subject to shared constraints that cause some correspondence among their state changes.some correspondence among their state changes.

Aggregation concurrency: the aggregate state corresponds to the combined states of all parts. Aggregation is the “and-relationship”. Aggregation concurrency: the aggregate state corresponds to the combined states of all parts. Aggregation is the “and-relationship”. The aggregate state is one state from the first diagram The aggregate state is one state from the first diagram andand the state from the second diagram and a state from each other diagram. the state from the second diagram and a state from each other diagram.

Page 20: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

The state of a CAR as an aggregation of part statesThe state of a CAR as an aggregation of part states

Page 21: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

You can partition some objects into subsets of attributes You can partition some objects into subsets of attributes or links each of which has its own sub diagramor links each of which has its own sub diagram

Page 22: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Sometimes one object must perform two (or more) activities concurrently. Sometimes one object must perform two (or more) activities concurrently. The objects does not synchronize the internal steps of the activities but The objects does not synchronize the internal steps of the activities but must complete both activities before it can progress to its next state. must complete both activities before it can progress to its next state.

Page 23: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Interaction ModelingInteraction Modeling

Interaction model is the third leg of the modeling tripod and describes interactions with in a system. The class model Interaction model is the third leg of the modeling tripod and describes interactions with in a system. The class model describes the objects in the system and their relationships. The state model describes the life cycles of the objects. describes the objects in the system and their relationships. The state model describes the life cycles of the objects.

The interaction model describes how the objects interact to produce useful results. Interaction can be modeled at different The interaction model describes how the objects interact to produce useful results. Interaction can be modeled at different levels of abstraction. At high level use cases describes how a system interacts with outside actors. Each use case represents levels of abstraction. At high level use cases describes how a system interacts with outside actors. Each use case represents a piece of functionality that a system provides to its users. Use cases are helpful for capturing informal requirements.a piece of functionality that a system provides to its users. Use cases are helpful for capturing informal requirements.

Page 24: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Interaction ModelingInteraction Modeling Sequence diagram provide more detail and show the messages exchanged among a set of objects over time. Messages include both Sequence diagram provide more detail and show the messages exchanged among a set of objects over time. Messages include both

asynchronous signals and procedure calls. Sequence diagrams are good for showing the behavior sequences seen by users of a asynchronous signals and procedure calls. Sequence diagrams are good for showing the behavior sequences seen by users of a systemsystem

Activity diagrams provide further detail and show the flow of control among the steps of computation. Activity diagrams can show Activity diagrams provide further detail and show the flow of control among the steps of computation. Activity diagrams can show data flows as well as control flows. Activity diagrams document the steps necessary to implement an operation or a business data flows as well as control flows. Activity diagrams document the steps necessary to implement an operation or a business process referenced in a sequence diagram.process referenced in a sequence diagram.

Page 25: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Use Case ModelsUse Case Models A use case is a set of scenarios that describing an interaction between a user and a system.  A use case diagram displays the

relationship among actors and use cases. The two main components of a use case diagram are ‘use cases’ and ‘actors’. An actor is a direct external user of a system. An actor represents a user or another system that will interact with the system you are

modeling. Each actor represents those objects that behave in a particular way toward the system. For example, customer and repair technician are different actors for a vending machine. An actor is a person, organization, or external system that plays a role in one or more interactions with your system

Page 26: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Use Case ModelsUse Case Models The various interactions of actors with a system are quantized into use cases. A use case is an external view of

the system that represents some action the user might perform in order to complete a task. A use case describes a sequence of actions that provide something of measurable value to an actor and is

drawn as a horizontal ellipse. A use case is a coherent piece of functionality that a system can provide by interacting with actors.

Page 27: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Use Case DiagramUse Case Diagram A system involves a set of use cases and a set of actors. Each use case represents a slice of the functionality the system provides.

The set of use cases shows the complete functionality of the system at level of detail. Similarly, each actor represents one kind of object for which the system can perform behavior. The set of actors represents the complete set of that the system can serve.

The are helpful in exposing requirements and planning the project. During the initial stage of a project most use cases should be defined, but as the project continues more might become visible. 

Page 28: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc Use case diagram for a vending machine

Page 29: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Guidelines for Use Case ModelsGuidelines for Use Case Models First determine the system boundary. Ensure that actors are focused.  Each use case must provide value to users. Relate use cases and actors. Remember that use cases are informal. Use cases can be structured.

Page 30: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Page 31: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Sequence ModelsSequence Models The sequence model elaborates the themes of use cases. There are two kinds of sequence models: Scenarios and a more structured format

called sequence diagrams. A usage scenario is a description of a potential way your system is used. The logic of a usage scenario may be part of a use case, perhaps an

alternate course. It may also be one entire pass through a use case, such as the logic described by the basic course of action or a portion of the basic course of action, plus one or more alternate scenarios. The logic of a usage scenario may also be a pass through the logic contained in several use cases. For example, a student enrolls in the university, and then immediately enrolls in three seminars

Page 32: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Sequence DiagramSequence Diagram A scenario can be displayed as a list of text statements. Sequence Diagram

A Sequence diagram depicts the sequence of actions that occur in a system. The invocation of methods in each object, and the order in which the invocation occurs is captured in a Sequence diagram. This makes the Sequence diagram a very useful tool to easily represent the dynamic behavior of a system. It shows the participants in an interaction and the sequence of messages among them. Also it shows the interaction of a system with its actors.

Page 33: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Sequence DiagramSequence Diagram

Page 34: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Sequence DiagramSequence Diagram Guidelines for sequence models The sequence model adds detail and elaborates the informal themes of use cases. Scenario document a sequence of events with prose. Sequence diagrams also document the sequence of events

but more clearly show actors involved.

• Prepare at least one scenario per use case.

• Abstract the scenario into sequence diagrams

• Divide complex interactions.

• Prepare a sequence diagram for each error condition.

Page 35: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Advanced Interaction ModelingAdvanced Interaction Modeling Use Case Relationships

It can be helpful to structure use cases for large applications. Complex use cases can be built from smaller pieces with the include, extend and generalization relationships

Include Relationship

The Include relationship incorporates one use case within the behavior sequence of another use case. An include use case is like a subroutine. It represents behavior that would otherwise have to be described repeatedly. The representation is a dashed arrow from source to destination. The keyword <<include>> annotates the arrow.

Page 36: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Advanced Interaction ModelingAdvanced Interaction Modeling

Page 37: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Advanced Interaction ModelingAdvanced Interaction Modeling Extend Relationship

The extend relationship adds incremental behavior to a use case. It is like an include relationship looked at from the opposite direction, in which the extension adds itself to the base, rather than the base explicitly incorporating the extension. It represents some frequent situations in which some initial capability is defined, and later features are added modularity. The include and extend relationship both add behavior to a base use case.

Page 38: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Advanced Interaction ModelingAdvanced Interaction Modeling Extend Relationship

Page 39: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Advanced Interaction ModelingAdvanced Interaction Modeling Generalization

In UML modeling, a generalization relationship is a relationship in which one model element (the child) is based on another model element (the parent). A generalization is used to indicate inheritance. Generalization relationships are used in class, component, deployment, and use case diagrams. A parent use case represents a general behavior sequence. Child use case specializes the parent by inserting additional steps of by refining steps.

Page 40: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Procedural Sequence ModelsProcedural Sequence Models Sequence Diagram with passive objects Sequence Diagram with transient object

Special Constructs for Activity ModelsSpecial Constructs for Activity Models

Sending and receiving signals Swimlanes

• Swimlanes can show organizational responsibility for activities Object Flows

Page 41: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Procedural Sequence ModelsProcedural Sequence Models Sequence Diagram with passive objects

Page 42: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Procedural Sequence ModelsProcedural Sequence Models Sequence Diagram with transient object

Page 43: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Special Constructs for Activity ModelsSpecial Constructs for Activity Models

Sending and receiving signals

Page 44: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Special Constructs for Activity ModelsSpecial Constructs for Activity Models Swimlanes

• Swimlanes can show organizational responsibility for activities

Page 45: Www.techstudent.co.cc State Modeling.  Events An event is an occurrence at a point in time, such as user depresses left button or

www.techstudent.co.ccwww.techstudent.co.cc

Special Constructs for Activity ModelsSpecial Constructs for Activity Models

Object Flows