NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
-
Upload
cornelia-morton -
Category
Documents
-
view
212 -
download
0
Transcript of NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
![Page 1: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/1.jpg)
NJIT
Modeling Behavior in State Chart Diagrams
Chapter 29
Rafael Mello
![Page 2: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/2.jpg)
Introduction
A State Diagram is drawn to show the life history of a reactive object. A reactive, event-driven, object is one whose behavior is best characterize by its response to events dispatched from outside its context. Objects are usually in a state, ex: Idle, until an event is trigger and makes the object transition from state to state. When that happens, its response usually depends on prior events.
![Page 3: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/3.jpg)
Events and States
Event – Is an occurrence that triggered the state. A telephone receiver is taken off the hook.
State – Is the condition of a object at a specific time. A telephone is on “idle” state until it is taken
from the hook.
![Page 4: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/4.jpg)
Transitions
Transition – Involves going from one state to the other when an event occurs. Transitions are label in form: Event [Guard] / Action When the event “off hook” occurs, transition
the telephone from the “idle” state to the “active” state.
![Page 5: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/5.jpg)
Statechart Diagrams
initial Statestate
transition
event
A Statechart diagram shows the lifecycle of an object
![Page 6: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/6.jpg)
Statechart Diagrams (Cont.)
The state diagram on the previous slide illustrates a simple telephone state chart diagram, with states, events and transitions. The states are shown in round rectangles. The transitions are shown with arrows, and the events are the labels in each transition.
![Page 7: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/7.jpg)
Use Case Statechart Diagrams
The Use Case Statechart diagram is used to describe the sequence of external events that is handled by a system described in a use case scope. Ex: In a Process Sale use case it is not permitted to perform a makeCreditPayment until the endSale event has happened.
![Page 8: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/8.jpg)
Classes that benefit from Statechart Diagram
In addition to Use Case and system design, the Statechart diagram can be used to describe object state behavior. Object can be state-independent or state-dependant. State-independent objects are objects that always respond the same way to an event. State-dependent objects are object that reacts different to events.
![Page 9: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/9.jpg)
When to use Statechart Diagrams
The next slide contains a list of common state-dependant objects that might be worth illustrating in a Statechart diagram:
![Page 10: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/10.jpg)
Classes that benefit from Statechart Diagram
Use Case – View as a class Stateful sessions – Server-side software
objects Systems – classes representing the system Windows – window’s action “Edit-Copy” Controllers – GRASP controller objects Transactions – The way transaction respond to
events Devices – Microwave oven, Radio Role Mutators – Classes that change its roles.
![Page 11: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/11.jpg)
Illustrating External and Interval Events
There are three types of events: External Event – Events caused by an outside
actor, outside of the system’s boundary. Internal Event – Events caused by an internal
action, inside the system’s boundary. Temporal Event – Events caused by a
determined date or time clock.
![Page 12: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/12.jpg)
Additional Statechart Diagram Notation
Additional features UML notation for statechart diagram: Transition actions Transition guard condition Nested states
![Page 13: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/13.jpg)
Additional Statechart Diagram Notation (Cont.)
Transitions are what makes an action to fire, such as a method invocation.
A transition also can have a Boolean test, such as a guard, that only happens if the test succeeds.
Nested states represents substates. The substate inherits the transitions of its superstate.
![Page 14: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/14.jpg)
Additional Statechart Diagram Notation (Cont.)
Example of Transition action and guard notation
![Page 15: NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.](https://reader036.fdocuments.in/reader036/viewer/2022083007/56649e7a5503460f94b7b71e/html5/thumbnails/15.jpg)
Additional Statechart Diagram Notation (Cont.)
Example of nested states