Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall 20032 Overview States Transitions Activities Modeling object lifeline Creating well-structured.

Similar presentations


Presentation on theme: "UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall 20032 Overview States Transitions Activities Modeling object lifeline Creating well-structured."— Presentation transcript:

1 UML Review: State Machines

2 Sept. 17, 2003Lecture 5: CS660 Fall 20032 Overview States Transitions Activities Modeling object lifeline Creating well-structured algorithms

3 Sept. 17, 2003Lecture 5: CS660 Fall 20033 Thermostat Example

4 Sept. 17, 2003Lecture 5: CS660 Fall 20034 Terms & Concepts State machine--behavior that specifies –the sequences of states an object goes through during its lifetime, and –the events and transitions between those states, and –responses to the events. State--condition or situation during the life of an object during which it satisfies some condition, performs some activity, or waits for some event.

5 Sept. 17, 2003Lecture 5: CS660 Fall 20035 Terms & Concepts (cont.) Event--specification of a significant occurrence that has a location in time and space. Transition--relationship between two states indicating that an object in the first state will perform certain actions and enter the second state upon occurrence of a specified event.

6 Sept. 17, 2003Lecture 5: CS660 Fall 20036 Terms & Concepts (cont.) Activity--ongoing non-atomic execution within a state machine. Action--executable atomic computation that results in a change in state of the model or the return of a value.

7 Sept. 17, 2003Lecture 5: CS660 Fall 20037 States State parts: –Name--distinguishing textual string; note: some states may be anonymous –Entry/exit actions--action executed on traversing a transition. –Internal transitions--no change in state. –Substates--nested structure of states –Deferred events--events not handled by a state, but are queued for later processing.

8 Sept. 17, 2003Lecture 5: CS660 Fall 20038 State Depicted in UML Rectangle with rounded corners. Initial state is filled black circle. Final state is an unfilled circle containing a filled black circle.

9 Sept. 17, 2003Lecture 5: CS660 Fall 20039 Transitions Transition parts: –Source state--the active state preceding the transition; it is affected by the transition. –Event trigger--event received by the source that causes the transition to “fire”. –Guard--boolean expression which must be true before the transition can fire. –Action--atomic computation that occurs during the transition. –Target state--the active state following the transition.

10 Sept. 17, 2003Lecture 5: CS660 Fall 200310 Transitions Depicted in UML

11 Sept. 17, 2003Lecture 5: CS660 Fall 200311 Advanced States Entry & exit actions--actions that always occur upon entry into or exit away from a state regardless of transition. Internal Transitions--triggered by events but don’t change state. Activities--ongoing behavior which continues until interrupted. Deferred events--events ignored by the current state, but postponed for later processing.

12 Sept. 17, 2003Lecture 5: CS660 Fall 200312 Advanced States (cont.)

13 Sept. 17, 2003Lecture 5: CS660 Fall 200313 Substates Substate--state nested inside of another state. Sequential substates History states Concurrent substates

14 Sept. 17, 2003Lecture 5: CS660 Fall 200314 Modelling Object Lifetime Set the context for the state machine: class, use case, or whole system. –Collect neighboring classes with any relationship; these are potential targets for actions and candidates for guards. –For an entire system, focus on one behavior of the system. Identify the initial and final states; define pre- and post-conditions

15 Sept. 17, 2003Lecture 5: CS660 Fall 200315 Modeling Object Lifetime (cont.) Decide on events to which the element will respond. Layout the top-level states and connect with appropriate transitions. Identify entry/exit actions. Expand states as necessary (identify substates)

16 Sept. 17, 2003Lecture 5: CS660 Fall 200316 UML is not Enough UML can represent many features But UML still cannot represent something –To model a network, how to represent routers & hubs. –How to keep track of the version number of a subsystem. –How to represent some constraints in a system.

17 Sept. 17, 2003Lecture 5: CS660 Fall 200317 UML Extension Mechanism Adornments –Notes Extensibility mechanisms –Stereotypes –Tagged values –Constraints Modeling Techniques Extending UML

18 Sept. 17, 2003Lecture 5: CS660 Fall 200318 Notes Notes—graphical symbol for rendering constraints or comments attached to an element or collection of elements. Representing the meaning of the model. Specify things like –Requirements –Observations –Reviews –Explanations –Constraints Rendered as a rectangle with a dog-eared corner.

19 Sept. 17, 2003Lecture 5: CS660 Fall 200319 Notes (cont.) May contain combination of text and graphics. May contain URLs linking to external documents. See http://www.omg.org for related information.http://www.omg.org See encrypt.doc for details about this algorithm.

20 Sept. 17, 2003Lecture 5: CS660 Fall 200320 Stereotypes Stereotype—extension of the UML vocabulary. Metatype Allows for new building blocks. Graphically rendered as –Name enclosed in guillemets > «stereotype» –New icon «metaclass» ModelElement Internet

21 Sept. 17, 2003Lecture 5: CS660 Fall 200321 Tagged Values Tagged value—extension of the properties of a UML element. Metadata—data applies to the element; not to instances of the element. Rendered as a text string enclosed in braces { } Placed below the name of another element. Properties; name/value pairs {name=value} > Billing {version=3.2}

22 Sept. 17, 2003Lecture 5: CS660 Fall 200322 Constraints Constraint—extension of the semantics of a UML element. Allows new or modified rules. –Conditions that must hold true. Rendered in braces {}. –Free-form text. –UML’s Object Constraint Language (OCL). –Can be contained in note.

23 Sept. 17, 2003Lecture 5: CS660 Fall 200323 Modeling Comments Place as text in note next to related element. Connect notes using dependencies if necessary. Hide or show as appropriate; Place lengthy comments in external files linked to the diagram through a note. Keep comments that record decisions. Keep historic comments.

24 Sept. 17, 2003Lecture 5: CS660 Fall 200324 Modeling New Building Blocks First attempt to use basic UML. Identify a basic UML component that closely approaches the new concept and define a stereotype. Specify properties and semantics using tagged values and constraints. For a distinctive visual cue, define a new icon.


Download ppt "UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall 20032 Overview States Transitions Activities Modeling object lifeline Creating well-structured."

Similar presentations


Ads by Google