Chapter 10 - State Diagrams

State dependent behaviour

This is where objects respond differently depending on their condition

For example, if a CD player has its drawer closed, then [LOAD] opens the drawer, and if the drawer is open, then [LOAD] closes the drawer.

Execution of state machines

The behaviour of a class can be represented in terms of a finite number of states. UML uses statecharts to model this.

Execution:

  • The current state is called the active state
  • When a transition to another state occurs, the transition is said to fire
  • Events that cause a transition to fire are called triggers
  • After a transition the new state becomes the acitve state

Events, states and activities

State diagrams

Charts the lifespan of an object. In some cases, from creation to destruction along with the descrete states in between. Where processes operate continuously, state diagrams show the state transition that occur in a cycle.

Event

Something that happens at a point in time. An event has no duration.

State

An abstraction of the attribute values and links of an object.

Activity

An operation that takes time to perform, while a partiular state of the object is active.

Action

An operation performed before/after a state change

Notation

Screenshot-2018-1-18-chapter10-state-diagrams-ppt.png

  • Black circle - Initial state - model the creation fo the objects
  • Back circle with black ring around it - final state - model the destruction of objects

Screenshot-2018-1-18-chapter10-state-diagrams-ppt(1).png

Relationship between state diagrams and class diagrams

A state diagram related to one class within a class diagram. The received events are often messages that will have originated at one of the other classes with which the class in qestion has a relationship.

Events are basically received messages and are therefore handled by a receiving class operation.

Actions - happening upon a state transition - are usually class operations that may result in a message being sent to another object

Activities - happening within a particular class state - are usually class operations

State diagrams are not flow diagrams - the rounded rectangles are states, not tasks.

Guard conditions

Guard conditions are shown in square brackets after the event

Screenshot-2018-1-18-chapter10-state-diagrams-ppt(2).png

Actions

Objects respond to events and often do something on detection. Actions are short and self contained. (long processes are represented another way). Actions can occur at the point of transition.

Composite states

Superstates. With a CD player, closed and open both have transitions to and from playing. States that share the same transitions can be grouped together.

Screenshot-2018-1-18-chapter10-state-diagrams-ppt(3).png

 

No Comments

Back to top