THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.

Slides:



Advertisements
Similar presentations
Behavioral Modeling: State Diagrams CIS 4800 Kannan Mohan Department of CIS Zicklin School of Business, Baruch College Copyright © 2009 John Wiley & Sons,
Advertisements

UML State chart/machine diagram State machine diagram is a behavior diagram which shows discrete behavior of a part of designed system through finite state.
1 Behavioral Modeling Chapter 8. 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports business processes.
ZEIT2301 Design of Information Systems Behavioural Design: State Machines School of Engineering and Information Technology Dr Kathryn Merrick.
Use Case Modeling SJTU. Unified Modeling Language (UML) l Standardized notation for object-oriented development l Needs to be used with an analysis and.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
Interaction Diagrams Activity Diagram State Machine Diagram
Object-Oriented Analysis and Design
Use-case Modeling.
1 CS 691z/791z Topics in Software Engineering Chapter 13: Activity Diagrams & Chapter 19: Basic Statecharts [Arlow and Neustadt, 2002] March 8, 2007.
State Machine Diagrams (State Chart in UML 1) Specifying Control (ref: Chapter 11 Bennett, Mc Robb and Farmer)
Modeling State-Dependent Objects Using Colored Petri Nets
1 CS/CPE 426 Senior Projects Chapter 21: State Machines Chapter 22:Advanced State Machines [Arlow and Neustadt 2005] March 24, 2009.
State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.
UML Sequence Diagrams Eileen Kraemer CSE 335 Michigan State University.
Advanced Behavioral Modeling
Slide 1 Chapter 8 Behavioral Modeling. Slide 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports.
SE-565 Software System Requirements More UML Diagrams.
University of Toronto Department of Computer Science © Steve Easterbrook. This presentation is available free for non-commercial use with attribution.
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
State Diagrams / System Sequence Diagrams (SSDs)
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Dynamic Modeling Chapter 11 Part of Analysis Modeling Designing Concurrent, Distributed, and Real-Time Applications with UML Hassan Gomaa (2001)
Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.
Behavioral Modeling Chapter 8.
CSIS3600 System Analysis and Design Statechart Diagrams.
1 A Student Guide to Object- Oriented Development Chapter 7 State Diagrams.
7 Systems Analysis and Design in a Changing World, Fifth Edition.
A Use Case Primer 1. The Benefits of Use Cases  Compared to traditional methods, use cases are easy to write and to read.  Use cases force the developers.
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 state charts 1 object states an object state is a condition or situation during the life.
The Unified Modeling Language Part II Omar Meqdadi SE 2730 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Version /05/2004 © 2004 Robert Oshana Requirements Engineering Use cases.
Software Engineering Design & Modeling Statechart Diagram.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
UML Discussion on State Machines Perfectly static system is intensely uninteresting Because nothing ever happens.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
CS212: Object Oriented Analysis and Design Lecture 34: UML Activity and Collaboration diagram.
Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams.
Systems Analysis and Design in a Changing World, Fourth Edition
States.
UML: State Chart Diagrams
CS3773 Software Engineering Lecture 06 UML State Machines.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Modeling Object Lifecycles and State-Dependent Behavior ©SoftMoore ConsultingSlide 1.
The Dynamic Analysis Model StateCharts Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
1 7 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 7 The Object-Oriented Approach to Requirements.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
Systems Analysis and Design in a Changing World, Fourth Edition
State Machine Model.
Dynamic Modeling of Banking System Case Study - I
Static and Dynamic Modeling Using UML
State Machine Diagrams
Finite State Machines and Statecharts
UML Activity Diagrams & State Charts
States.
Object Oriented System Design
CS/CPE 426 Senior Projects
Finite State Machines and Statecharts
CS/CPE 426 Senior Projects
Marlon Dumas Institute of Computer Science
States.
CS 791Z State Machines & Advanced State Machines
UML Diagrams: StateCharts The Dynamic Analysis Model
UML State Diagrams.
Presentation transcript:

THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams

l Activity diagram versus a statechart diagram –Both model DYNAMIC behavior of a system –Activity diagrams are a special case of a statechart diagram where the states are actions and the transitions are triggered automatically by the completion of a state’s action and activities –Activity diagrams tend to be used for modeling business processes where several objects participate –Statechart diagrams tend to be used for modeling the lifecyle history of a single reactive object (respond to external events, have states and transitions) –Statechart most commonly used to model dynamic behavior of classes

Statechart Diagrams l Statechart Diagram –Statecharts (state diagrams) show the lifetime behavior of a single object –Used to capture dynamic behavior by describing all possible states and state changes as a result of events that reach the object

Finite State Machine (FSM) l A finite state machine is a conceptual machine with a finite number of states l It can be in only one of the states at any specific time l A state transition is a change in state that is caused by an input event l The next state depends on the current state as well as the input event l In UML, a state transition diagram is called a state chart

State Machines

States l The UML Reference Manual defines a state as, “a condition or situation during the life of an object during which it satisfies some condition, performs some activity, or waits for some event”. l The state of an object varies over time, but at any particular point it is determined by: –the object attribute values –the relationship it has to other objects –the activities it is performing l Key to successful statechart modeling is identifying the states that make a difference in your system

States

State Syntax EnteringPassword entry/display password exit/validate alphaKeypress/echo “*” help/display do/get state name entry and exit actions internal transitions internal activity Each state may contain zero or more actions and activities Actions are instantaneous and uninterruptible Activities take a finite amount of time and can be interrupted

Simple Example – Light Bulb Off On turnOffturnOn event trigger

Simple Example – Bank Account

Actions & Activities l Two special actions: –Entry action (associated with entry event) –Entry event occurs instantaneously and automatically on entry into the state »It is the first thing that happens when the state is entered »Causes the associated entry action to execute –Exit event is the last that happens instantaneously and automatically on exit from the state »Causes the associated exit action to execute l Activities take a finite time and may be interrupted by the receipt of an event –Keyword do indicates an activity –May not finish due to interruption

Transitions l UML Syntax l anEvent – this is an external or internal occurrence that triggers the transition l guardCondition – this is a Boolean expression the must evaluate to TRUE before a transition can occur l anAction – this is a piece of work associated with the transition and occurs when the transition fires

Transitions

Events and External Actions l State transitions occur in response to events l If there is more than one transition out of a state, a guard condition determines which transition is fired l An action may occur when the transition fires (multiple actions should be expressed in a comma separated list) l If there is no action associated with a transition, the event only causes the change of state, and there is no observable response from the object unless it has internal actions State_1 State_2 entry / entry_action exit / exit_action do / activity event [guard] / action

Types of Events l Call event –simplest type of event –the receipt of a call event is a request for a set of actions to occur –Really just a request for a specific method to be invoked Bank Acccount

Types of Events l Signal Event –Package of information that is sent asynchronously between objects –Modeled as a stereotyped class that contains all of the communication information as its attributes

Types of Events l Change events –has the keyword when, and then a Boolean expression –action associated with the event is performed when the Boolean expression is true –All values in the Boolean expression must be attributes of the context class

Time Events l Time events are denoted by the keywords when and after –keyword when specifies a particular moment in time that the event triggered –keyword after specifies a threshold time after the event triggered »e.g. after (3 months) and when (date = 08/04/04)

Methods and attributes l The state of an object will be determined by the values of the attributes of the class –in many cases, only a subset of the attributes will be relevant for modelling the state –looking at the attributes should help identify possible states –an event causing a change of state leads to a change in the object’s attribute values l Events can be implemented as public methods –the object is notified of an event by receiving a message from another object l Actions and activities should be implemented as private methods –it should not be possible for actions to be invoked without a valid event occurring l Entry, exit and internal actions should also be private methods

Guidelines for Developing Statecharts l A state name must reflect an identifiable situation or an interval of time when something is happening in the system. l Each state must have a unique name. l It must be possible to exit from every state. l On a flat (not hierarchical, composite) statechart, the system is in one state at a time. l An event is the cause of the state transition. An action is the effect of the state transition. l An event happens at a moment of time; an action happens instantaneously; an activity executes throughout a state. l Actions, activities and conditions are optional. Use only as necessary.

Developing Statecharts from Use Cases l To develop a statechart from a use case, start with a typical scenario given by the use case. –This scenario should be the most typical path through the use case, involving the most usual sequence of interactions between the actor(s) and the system. l Then consider the sequence of external events given in the scenario. –In each case, an input event from the external environment causes a transition to a new state. –An action or an activity may associate with the transition. –Actions and activities are determined by considering the response of the system to the input event, as given in the use case description.

Developing Statecharts from Use Cases l Initially, a flat statechart is developed following the event sequence given in the scenario. l To complete the statechart, determine all the possible external events that could be input to the statechart. –You do this by considering the description of alternative paths given in the use case.

Example of Developing a Statechart from a Use Case l Actor: Driver l Summary: This use case describes the automated cruise control of the car, given the driver inputs via the cruise control lever, brake, and engine external input devices. l Precondition: Driver has switched on the engine and is operating the car manually. l Description: –1. Driver releases the cruise control lever in order to cruise at a constant speed. The system stops automatic acceleration and starts maintaining the speed of the car at the cruising speed. The cruising speed is stored for future reference. –2. Driver presses the brake to disable cruise control. The system disables cruise control so that the car is once more under manual operation. –3. Driver moves the cruise control lever to the ACCEL position and holds the lever in this position. The system initiates automated acceleration so that the car automatically accelerates.

Example of Developing a Statechart from a Use Case l Description (continued): –4. Driver moves the cruise control lever to the RESUME position in order to resume cruising. The system initiates acceleration (or deceleration) toward the previously stored cruising speed. –5. When the system detects that the cruising speed has been reached, it stops automatic acceleration (or deceleration) and starts maintaining the speed of the car at the cruising speed. –6. Driver moves the cruise control lever to the OFF position. The system disables cruise control, so the car is once more under manual operation. –7. The driver stops the car and switches off the engine.

Example of Developing a Statechart from a Use Case l Alternatives: –1. The Accel, Cruise, Resume, and Off external events from the cruise control lever. The Accel event causes automated acceleration, providing the brake is not pressed. The Cruise event may only follow an Accel event. The Resume event may only occur after cruising has been disabled and the desired cruising speed has been stored. The Off event always disables cruise control. –2. The Brake Pressed and Brake Released external events from the brake. The Brake Pressed event always disables cruise control. Automated vehicle control is not possible as long as the brake is pressed. After the brake is released, automated vehicle control may be enabled. –3. The Engine On and Engine Off external events from the engine. The Engine Off event disables any activity in the system. l Postcondition: –The car is stationary, with the engine switched off.

Cruise Control Statechart

Statechart Example – SSN Pin Validation

ATM Example

ATM Example – Single Session

Loan Approval Example

ISP Dial-UP Example

Modeling the Lifetime of an Object