CPS122 Lecture: State and Activity Diagrams in UML



Similar documents
Object Oriented Programming. Risk Management

Writing Use Case Scenarios for Model Driven Development

Model Simulation in Rational Software Architect: Business Process Simulation

CPS122 - OBJECT-ORIENTED SOFTWARE DEVELOPMENT. Team Project

UML basics. Part II: The activity diagram. The activity diagram's purpose. by Donald Bell IBM Global Services

Case studies: Outline. Requirement Engineering. Case Study: Automated Banking System. UML and Case Studies ITNP090 - Object Oriented Software Design

Using Rational Rose to Create Object-Oriented Diagrams

Using UML Part Two Behavioral Modeling Diagrams

Statgraphics Getting started

Introduction. UML = Unified Modeling Language It is a standardized visual modeling language.

Company Setup 401k Tab

Using Microsoft Project 2000

Process Modeling Notations and Workflow Patterns

Notes on Excel Forecasting Tools. Data Table, Scenario Manager, Goal Seek, & Solver

Part 1 Foundations of object orientation

Configuration Manager

Lab 1: Introduction to Xilinx ISE Tutorial

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

Using Use Cases for requirements capture. Pete McBreen McBreen.Consulting

Creating tables of contents and figures in Word 2013

Creating a table of contents quickly in Word

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Modifying Colors and Symbols in ArcMap

Petrel TIPS&TRICKS from SCM

LESSON 7: IMPORTING AND VECTORIZING A BITMAP IMAGE

SolidWorks Tutorial 3 MAGNETIC BLOCK

Creating a PowerPoint Poster using Windows

Process Modeling using BPMN 2.0

User experience storyboards: Building better UIs with RUP, UML, and use cases

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

Presentations and PowerPoint

Select the Crow s Foot entity relationship diagram (ERD) option. Create the entities and define their components.

F&M s Online Bulletin Board

TestManager Administration Guide

University of Arkansas Libraries ArcGIS Desktop Tutorial. Section 2: Manipulating Display Parameters in ArcMap. Symbolizing Features and Rasters:

Offline Files & Sync Center

MS Project Tutorial for Senior Design Using Microsoft Project to manage projects

Requirements Document for the Banking System. Lecture # 40

Petrel TIPS&TRICKS from SCM

EXPRESS PCB TUTORIAL Author: Lee Morey Revised: JE Feb 2015

Multiagent Control of Traffic Signals Vision Document 2.0. Vision Document. For Multiagent Control of Traffic Signals. Version 2.0

Announcements. SE 1: Software Requirements Specification and Analysis. Review: Use Case Descriptions

5. Tutorial. Starting FlashCut CNC

RADIOTHERAPY COST ESTIMATOR USER GUIDE

Object Oriented Design

Lecture 8: Synchronous Digital Systems

To complete this workbook, you will need the following file:

Sequence Diagram Tutorial. From: UML Distilled, Third Edition, Chapter 4 M. Fowler

Introduction to the File Manager

Search help. More on Office.com: images templates

Wireless Setup Guide. Windows XP, Vista, 7 & 8

Creating 2D Isometric Drawings

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

EDIT202 PowerPoint Lab Assignment Guidelines

Manual English KOI Desktop App 2.0.x

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

2: Entering Data. Open SPSS and follow along as your read this description.

Weather Direct Displays show Lost Forecast (blank boxes in the picture icons)

Deposit Direct. Getting Started Guide

Excel Graphs and Printing from PowerPoint

MET 306 Activity 6. Using Pro/MFG Milling Operations Creo 2.0. Machining a Mast Step

COPYRIGHT TOP NOTCH TABLETS LLC HOW TO: Install the Drivers to your PC so you can Flash Firmware to your RK3066 Powered Tablet.

BPMN Business Process Modeling Notation

TRAFFIC LIGHT: A PEDAGOGICAL EXPLORATION

Creating a Gradebook in Excel

If you know exactly how you want your business forms to look and don t mind

Communication Process

Tutorial for Tracker and Supporting Software By David Chandler

? Index. Introduction. 1 of 38 About the QMS Network Print Monitor for Windows NT

Design Report: Resource Management Software CS400 Senior Design I

Completing a Quiz in Moodle

Chapter 3. Technology review Introduction

Working with sections in Word

Chapter 1. Creating Sketches in. the Sketch Mode-I. Evaluation chapter. Logon to for more details. Learning Objectives

WIRELESS TRAINING SOLUTIONS. by vlogic, Inc. L a b 0.3 Remote Access Labs

ITS Training Class Charts and PivotTables Using Excel 2007

Data Flow Diagram (DFD) Tutorial Written Date : January 27, 2012

Table Of Contents. iii

How to test and debug an ASP.NET application

Designing a Graphical User Interface

OVERVIEW. Microsoft Project terms and definitions

Jump-Start Tutorial For ProcessModel

Vanderbilt University School of Nursing. Running Scopia Videoconferencing from Windows

2 SYSTEM DESCRIPTION TECHNIQUES

SMART BOARD USER GUIDE FOR PC TABLE OF CONTENTS I. BEFORE YOU USE THE SMART BOARD. What is it?

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

[1] [2]

Design and UML Class Diagrams. Suggested reading: Practical UML: A hands on introduction for developers

8 Creating a Workflow

Colorado Medical Assistance Program Web Portal Dental Claims User Guide

Photoillustration: Harold A. Perry; photos: Jupiter Images

PA Actions Final Review [ BHR Services Team > Initiator > BHR Services Team] Process:

Instruction Set: Hiring a Work Study Student

Applied Biosystems 3730xl at DBS Step-by-Step Guide

SMART board 101. SMART board 101 Training

ATM Case Study OBJECTIVES Pearson Education, Inc. All rights reserved Pearson Education, Inc. All rights reserved.

einstruction CPS (Clicker) Instructions

Visual Dialogue User Guide. Version 6.1

Tutorial - Building a Use Case Diagram

Chapter 4: Tools of Modern Systems Analysis

Transcription:

CPS122 Lecture: State and Activity Diagrams in UML Objectives: last revised February 14, 2012 1. To show how to create and read State Diagrams 2. To introduce UML Activity Diagrams Materials: 1. Demonstration of Racers program 2. Executable of Video Store project initial software to be given students 3. Handout: State diagram for Session 4. Handout: Code for Session class performsession() method 5. Handout of Activity diagram for Racers I. Introduction A. We have drawn a distinction between the static aspects of a system and its dynamic aspects. The static aspects of a system have to do with its component parts and how they are related to one another; the dynamic aspects of a system have to do with how the components interact with one another and/or change state internally over time. B. We have been looking at one aspect of the dynamic behavior of a system - the way various objects interact to carry out the various use cases. We have looked at two ways of describing this: 1. Sequence diagrams 2. Communication diagrams C. We now want to look two additional aspects of dynamic behavior 1. How an individual object changes state internally over time. 1

a) Example: As part of doing the domain analysis of a traffic light system, it is important to note that individual signals go through a series of states in a prescribed order - modeled by the following state diagram: (Note: this is correct for the US but not for all countries in the world!) An important business rule that any traffic light system must obey is that the light must be yellow for a certain minimum period of time (related to vehicle speed in the intersection) between displaying green and displaying red. Ensuring that a system exhibits this behavior is essential for safety. b) Note the difference between an interaction diagram and a state diagram - the former deals with how several objects work together to accomplish one use case; the latter deals with the internal state of one object, which may be affected by multiple use cases. Compare with a person s internal state versus interactions with others. The class session use case involves several Student objects and a Professor object. Something that happens in class may affect the internal state of a student (e.g. getting back a test with a good (or for that matter bad) grade). The internal state of a Student object (e.g. sleepy) affects not only this use case, but also others like chapel. 2

2. The possibility that several different things may be happening in parallel at the same time. Example: Demonstrate Racers program. Note: we will discuss this more thoroughly in CPS221 II. State Diagrams A. We will now consider a tool that can be used to model this aspect of the behavior of an object: The State Diagram. It can be used either for analysis (if our goal is to record how behavior actually transpires in a system we are modeling) or for design (if our goal is to describe a behavior we want to produce.) Note: UML 1 referred to these as statechart diagrams; UML 2 calls them State Machine Diagrams - sometimes shortened to State Diagrams. B. Often, while we analyze a system, we discover that some objects in a system undergo defined state transitions over time, which is an important part of the dynamic behavior of the system. 1. Example: we just looked at an example of this in the domain of traffic lights. 2. What about our ATM example? ASK a) The ATM itself (represented by an ATM object in our case) goes through a series of states (off, on, serving a customer, etc.) b) Individual sessions pass through a series of states 3

c) Individual transactions also pass through a series of states. (Note that the objects that have this characteristic are often controller objects.) C. In such cases, it may prove helpful to develop a State Diagram, showing the states it passes through - especially if there is any complexity to the state transitions. 1. Example: We will develop a state diagram for a session. a) Referring to the use case for a session, what distinct states can we identify? ASK (1)Reading card (2)Asking for PIN (3)Asking for transaction choice (4)Performing transaction (5)Ejecting card at the end of the session (6)Session finished b) Further, the transitions between states for a session follow a fairly complex pattern - e.g. (1)After reading a card, we go either to asking for PIN or to ejecting card, depending on whether the card was readable. 4

(2)After asking for PIN, we normally go to asking for a transaction choice; but we go to ejecting card if the customer presses cancel. (3)After asking for a transaction choice, we normally go to performing the transaction, but we go to ejecting card if the customer presses cancel. (4)After performing a transaction, we can go one of three ways: (a) To choosing transaction, if customer says he/she wants to do another. (b)to ejecting card, if customer says he/she doesn t want to do another. (c) To session finished, if the card was retained due to too many invalid PINs. c) PROJECT STATE DIAGRAM FOR SESSION FROM WEB + HANDOUT d) We have already noted that there are other objects for which such a diagram would prove useful. ASK SHOW REMAINING STATE DIAGRAMS ON WEB 2. In general, a state diagram is a useful analysis tool for: a) An object that is responsible for a use case, provided that the use case has enough internal complexity to warrant doing a state diagram. (If the use case consists of just a few steps, with no complex variation in sequencing, then a state diagram may not be warranted.) 5

b) An object has complex internal states, even though it is not directly responsible for a use case Example: In the case of the ATM simulation, the object representing the network connection to the bank would likely warrant a state diagram, because network connections typically pass through a series of states as they dialog with a peer on the other end. We have omitted that from the example, because we ve avoided getting into the details of how the network connection works. A real system would, of course, have to deal with this. D. Another place where state diagrams are often useful is in the design of graphical user interfaces. We will say more about UI design later, but for now we want to focus on how state diagrams can be used. 1. The states correspond to the different visible states of the GUI - i.e. what screen etc. is being displayed and what buttons/menus are active. 2. The transitions correspond to the various user gestures - i.e. options the user may choose. 3. For your project, you will be creating a state diagram for the overall GUI for the video store software. Let s spend a few moments now constructing a portion of it - the portion that pertains to checking out videos. DEMONSTRATION: Video Store GUI - Rent Tab a) No ID typed - clicking OK ignored b) Bad ID (type bad ) entered - error message 6

c) Valid ID entered - goes to details screen. (1)Provision for maintaining a list of items to rent (a) ID field blank - clicking Add item ignored (b)bad ID (type bad ) entered - error message (c) Can add a valid item (d)remove item affects selected item; ignored if one selected (e) Clear all items has no effect if list is empty (2)Two possible states to screen (a) No items listed - Only Cancel can be clicked (b)items listed - OK is also enabled 4. Develop state diagram for this portion as a class with three states - Rent tab displayed; rent details card with no items listed; rent details card with items listed E. A State diagram makes use of several symbols: 1. A rounded rectangle denotes a state. 2. Arrows connecting states denote state transitions. A transition is labeled with one or two pieces of information a) The situation under which the transition occurs (always) (1)This may take the form of a label on the transition itself. (2)There may also be a guard associated with the label. 7

Example: If we were modeling a ChargeAccount object (representing a credit card account), we might have states current and overdue, with a payment transition from overdue to current guarded by the condition amount minimum Current payment [ amount minimum ] Overdue b) Action that takes place on the transition (optional) (in our examples, actions appear on the transitions for the ATM itself, but not for Session and Transaction.) 3. A filled in dot denotes the initial start - where the system starts. 4. A filled in dot in a circle denotes a final state. When a system reaches the final state, no further state transitions are possible. (Note that the diagrams for Session and Transaction have final states; but the ATM state diagram does not - turned off is one of its states, but there is no final state per se because it can always be turned back on.) 5. Additional notation is possible, but this is more advanced than what we want to talk about now. F. It is also possible to incorporate information about specific actions to be performed during a state, or when entering or leaving it. 1. The state diagram for the Overall ATM includes entry actions for two of the three states. These are performed as soon as the state is entered. 8

2. A state can also have an exit action, to be performed just before leaving the state. 3. A state can have a do action, to be performed continuously while in the state. Figure 7.12 on page 193 illustrates all of these - though the illustration is a bit forced. Actually, just the do action is all that s needed! G. Finally, it is sometimes helpful to incorporate a state diagram within another state diagram, describing a complex internal structure for a single state. 1. This can be done by physically incorporating the nested state diagram into the larger state on the diagram. EXAMPLE: Text Fig. 7.13 p. 194 2. Alternately, the sub diagram can be drawn separately and referenced by an include in the containing state EXAMPLE: The overall ATM diagram s SERVING CUSTOMER state explicitly includes the entire Session state diagram; its PERFORMING TRANSACTiON state explicitly includes the Transaction state diagram. 3. Physical inclusion is necessary, when the sub diagram can be entered at more than one place. Inclusion by the use of include makes an easier to read diagram if the included state diagram has only a single entry point. H. A state diagram can often be translated into code in a very straightforward way that preserves the clarity of the state diagram HANDOUT: Code for performsession () method of Session - compare to State Diagram on the web. 9

I. Class Exercise: Develop a state diagram for a single video in a video store. 1. What states can it be in? ASK On shelf (in the store) Checked out to a customer On hold (at the desk, waiting for a customer to pick it up) On rack to be sold. 2. Draw states, fill in transitions.- including initial state, and possibility of discarding or selling - each leading to final state. III.UML Activity Diagrams A. One of the chapters in the book that you read for today discussed a type of UML Diagram called an Activity Diagram. Such a diagram can be constructed for a simple program, but it is particularly useful for showing processes in which there is concurrent processing. EXAMPLE: HANDOUT: Activity Diagram for Racer Problem B. Features: 1. Rounded rectangles represent activities. 2. Arrows represent flow from one activity to the next. Each activity is assumed to start as soon as its predecessor completes. 3. Where there is concurrency, the diagram shows forking of one thread into two or more, and joining of two or more threads into one. (Forks and joins should match.) 10

4. The diagram uses swim lanes to show the various parts of the system that are performing a task concurrently. C. ANOTHER EXAMPLE: Figure 8.10 on page 209 of the book. In this case the diagram is showing concurrency between three humans and the computer. D. We will say more about use of concurrency in programs in CPS221. 11