CSE 403 Lecture 9 UML State Diagrams Reading:

Slides:



Advertisements
Similar presentations
© 2005 by Prentice Hall Appendix 3 Object-Oriented Analysis and Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
Advertisements

State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
Object-Oriented Analysis and Design
CS 425/625 Software Engineering System Models
State Diagram. What is State Diagram?  State diagram is used to show the state space of a given class, the events that cause a transition from one state.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
Understanding class definitions Looking inside classes.
SE-565 Software System Requirements More UML Diagrams.
UML Sequence Diagrams Reading: UML Distilled Ch. 4, by M. Fowler
UML for Java Programmers Object Mentor, Inc. Copyright  by Object Mentor, Inc All Rights Reserved
Sequence Diagram Tutorial
1 CSE 331 The Strategy and State Patterns slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Chapter 10 State Machine Diagrams
Business Informatics Group Institute of Software Technology and Interactive Systems Vienna University of Technology Favoritenstraße 9-11/188-3, 1040 Vienna,
NJIT Modeling Behavior in State Chart Diagrams Chapter 29 Rafael Mello.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Systems Analysis and Design in a Changing World, 6th Edition
Guide to State Transition Diagram. 2 Contents  What is state transition diagram?  When is state transition diagram used?  What are state transition.
Internet Software Development Controlling Threads Paul J Krause.
Chapter 5 Implementing UML Specification (Part II) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
UML Discussion on State Machines Perfectly static system is intensely uninteresting Because nothing ever happens.
Session 13 Pinball Game Construction Kit (Version 3):
CSE 403 Lecture 9 UML State Diagrams Reading:
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 State Behavior Patrick Bailey Keith Vander Linden Calvin College.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 UML State Diagrams.
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 26. Review UML behavioral Diagrams – Sequence diagram.
1 CSE 331 Model/View Separation and Observer Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
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.
Chapter 3: Introducing the UML
CSE 403 Lecture 8 UML Sequence Diagrams Reading: UML Distilled, Ch. 4, M. Fowler slides created by Marty Stepp
Chapter 1 Overview of UML for Java Programmers. 2 Outline Diagram Types Diagram Types Class Diagrams Class Diagrams Object Diagrams Object Diagrams Sequence.
EKT 421 SOFTWARE ENGINEERING
Systems Analysis and Design in a Changing World, Fourth Edition
Algorithms and Problem Solving
Chapter 4: Business Process and Functional Modeling, continued
UML Diagrams By Daniel Damaris Novarianto S..
State Machine Diagram.
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Standard UML: Communication and Dynamic Behavior
Chapter 11: Collaboration Diagram - PART1
Unified Modeling Language
UML UML Sequence Diagrams CSE 403
Today’s Objectives Define the Problem Domain
UML Diagrams Jung Woo.
State Machine Diagrams
Business System Development
Creating and Using Classes
UML State machine diagram
System Sequence Diagrams
States.
Advanced State Chart diagrams
Classification of UML Diagrams
State Diagrams.
CIS 375 Bruce R. Maxim UM-Dearborn
States.
Algorithms and Problem Solving
Visual Modeling Using Rational Rose
CIS 375 Bruce R. Maxim UM-Dearborn
Expanding the PinBallGame
UML State Diagrams.
Appendix 3 Object-Oriented Analysis and Design
Abstract Types Defined as Classes of Variables
UML State Diagrams (Ch. 29)
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

CSE 403 Lecture 9 UML State Diagrams Reading: UML Distilled, Ch. 10, M. Fowler slides created by Marty Stepp http://www.cs.washington.edu/403/

UML state diagrams state diagram: Depicts data and behavior of a single object throughout its lifetime. set of states (including an initial start state) transitions between states entire diagram is drawn from that object's perspective similar to finite state machines (DFA, NFA, PDA, etc.) What objects are best used with state diagrams? large, complex objects with a long lifespan domain ("model") objects not useful to do state diagrams for every class in the system!

State diagram example

States state: conceptual description of the data in the object represented by object's field values entire diagram is drawn from the central object's perspective only include states / concepts that this object can see and influence don't include every possible value for the fields; only ones that are conceptually different

Transitions transition: movement from one state to another signature [guard] / activity signature: event that triggers (potential) state change guard: boolean condition that must be true activity: any behavior executed during transition (optional) transitions must be mutually exclusive (deterministic) must be clear what transition to take for an event most transitions are instantaneous, except "do" activities

Internal activities internal activity: actions that the central object takes on itself sometimes drawn as self-transitions (events that stay in same state) entry/exit activities reasons to start/stop being in that state

State diagram example User account management

Super/substates When one state is complex, you can include substates in it. drawn as nested rounded rectangles within the larger state Caution: Don't over-use this feature. easy to confuse separate states for sub-states within one state

State diagram example ATM software states at a bank

State diagram example Java thread states

Implementing states What are some ways to write code to match a state diagram? state tables (pseudo-code) nested if/else switch statements state enums State design pattern

State pattern state pattern: An object whose sole purpose is to represent the current "state" or configuration of another larger object. A behavioral pattern. Often implemented with an enum type for the states. Each object represents one specific state for the larger object. The larger object sets its state in response to various mutations. Allows various observers and interested parties to quickly and accurately know what is going on with the larger object's status. Analogous to the notion of finite state machines. Set of states (nodes) Set of edges (mutations that cause state changes) difference from Command pattern: command objects each solve different problems strategy objects all solve the same problem in different ways

State enum example /** Represents states for a poker game. */ public enum GameState { NOT_STARTED, IN_PROGRESS, WAITING_FOR_BETS, DEALING, GAME_OVER; } /** Poker game model class. */ public class PokerGame { private GameState state; public GameState getState() { return state; } public void ante(int amount) { ... state = WAITING_FOR_BETS; // change state setChanged(); notifyObservers(state);