Presentation is loading. Please wait.

Presentation is loading. Please wait.

Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 State Behavior Patrick Bailey Keith Vander Linden Calvin College.

Similar presentations


Presentation on theme: "Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 State Behavior Patrick Bailey Keith Vander Linden Calvin College."— Presentation transcript:

1 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 State Behavior Patrick Bailey Keith Vander Linden Calvin College

2 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 2 State Behavior ● Objects can display: – Reactive, state-independent behavior – Discrete, state-dependent behavior – Continuous behavior ● UML models this intra-object behavior using State Machine diagrams.

3 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 3 State Machine Diagrams ● State diagrams can be specified for classes, use cases, or other systems. ● They specify object behavior over a number of use cases. ● Key elements: – States – Transitions

4 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 4 Example: State Machine Diagram Example from www.ilogix.com, August, 2005www.ilogix.com

5 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 5 Outline ● History History ● State Diagrams State Diagrams ● Implementing State Transitions Implementing State Transitions ● Using State Diagrams Using State Diagrams

6 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 6 ● Developed statecharts, a higraph-based amalgam of graphs and Venn diagrams. ● Statecharts are the basis of UML state machine diagrams. David Harel State Charts Image from www.wisdom.weizmann.ac.il, August, 2005www. Harel’s original digital watch state chart

7 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 7 States ● Use states to represent conditions of objects in time. ● Internal Activities: – On Entry – On Exit – Internal Transition – Do Activities

8 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 8 Transitions ● Transitions indicate movement from one state to another. ● Syntax: event-name ( parameter-list ) [ guard-expression ] / action-list

9 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 9 Transition Events ● Events that can trigger transitions include: – Signal events – Call events – Time events – Change events ● Transitions without events and guards are followed immediately.

10 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 10 Super-States Use super-states to represent sets of states that share common transitions and activities.

11 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 11 Action Execution Order ● Actions are executed in this basic order: – Exit actions – Transition actions – Entry actions ● In the context of super/sub-states, outer actions are executed before inner actions.

12 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 12 And States & Or States ● We’ve already seen Or states. ● And states represent orthogonal state spaces. Example from Fowler, M., UML Distilled, 2004.

13 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 13 Example

14 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 14 Pseudo-States Pseudo-states are state- like constructions that represent a variety of things, including: – Conditions – History – Termination – Branching varieties

15 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 15 Example

16 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 16 Implementing State Diagrams Code generators can implement state behavior in several ways: – Nested switch statements – State pattern – State table

17 Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 17 Using State Diagrams ● State diagrams represent intra-object behavior. ● Combine them with other diagrams to represent inter-object behavior. ● Use them only for objects with “interesting” state-based behavior. ● Take care to avoid: – Ambiguous specifications – Race conditions


Download ppt "Smith’s Aerospace © P. Bailey & K. Vander Linden, 2006 State Behavior Patrick Bailey Keith Vander Linden Calvin College."

Similar presentations


Ads by Google