Arab Open University
2nd
Semester, 2006-2007
M301
Unit 4.5
States and Activities
reem.attas@arabou.org.sa
Reem AlAttas © 2
Topic Road Map
 Capturing more complex interactions
Design issues
An introduction to state machines
Variation of events and actions
Packages
Conditional Message Sends
in Sequence Diagrams
Reem AlAttas © 4
If Statement
Guard
Reem AlAttas © 5
If .. Else Statement
Mutually
Exclusive
Branch
Iterative Message Sends in
Sequence Diagrams
Reem AlAttas © 7
For Loop
Reem AlAttas © 8
Topic Road Map
Capturing more complex interactions
 Design issues
An introduction to state machines
Variation of events and actions
Packages
Reem AlAttas © 9
Defensive Programming
Pre-conditions should always be checked.
Disadvantage: conditions are repeatedly
checked in different places.
Reem AlAttas © 10
Strategies for Implementing Use Cases
One Central Class.
Actor Class.
Use Cases as Classes.
Reem AlAttas © 11
Topic Road Map
Capturing more complex interactions
Design issues
 An introduction to state machines
Variation of events and actions
Packages
Reem AlAttas © 12
The Essentials of State Machines
 An event is an occurrence of a phenomenon at a
certain moment in time and in a certain place.
 Each state represents a particular period for
which a given set of conditions applies.
 Change takes place through transitions from one
state to another. Transitions are said to be fired
or triggered by events.
Reem AlAttas © 13
Two Simple States for a Room Object
Initial
State
Event
Transition
Reem AlAttas © 14
… The Essentials of State Machines
 An event when it occurs, has consequences.
One consequence is a change of state. Other
consequences are recorded in the action part of
the label on the transition.
 That is, instead of labeling a transition just with a
simple name, we also record the actions
(consequences) that result from the occurrence
of the event.
Reem AlAttas © 15
Check In Sequence Diagram
Reem AlAttas © 16
Adding Detail to a State Machine for a
Room Object
Event
Action
;
aGuest.setRoom (self)
Reem AlAttas © 17
A Simple State Machine for the Hotel
Class
Self
Transition
Reem AlAttas © 18
Self Transition
 Originates in one state and returns to the same
state.
 If the same event is used on more than one
transition, you must make sure that no more
than one guard can evaluate to true. At most,
you want just one transition to fire in such
situations.
Reem AlAttas © 19
Entry and Exit Events
An entry event happens every time an
object enters a state.
An exit event happens every time an
object leaves a state.
Reem AlAttas © 20
… Entry and Exit Events
Reem AlAttas © 21
Internal Transition
A special transition that does not involve a
change of state.
In contrast to a self-transition, an internal
transition does not cause the execution of
any entry or exit actions.
Reem AlAttas © 22
… Internal Transition
 An internal transition may be used to handle an interrupt
where you want some action to take place that does not
affect the current state.
 Internal transitions are written inside the state to which
they refer.
Reem AlAttas © 23
Final State
 A state chart diagram shows no more than one initial
state but there can be zero, one or more final states.
 Initial and final states signify the creation and destruction
of an object.
Reem AlAttas © 24
Topic Road Map
Capturing more complex interactions
Design issues
An introduction to state machines
 Variation of events and actions
Packages
Reem AlAttas © 25
Other Kinds of Events
External Vs. Internal Events.
Synchronous Vs. Asynchronous Actions.
UML defined 4 types of events:
 Call Events.
 Signal Events.
 Change Events.
 Time Events.
Reem AlAttas © 26
Time Event
Reem AlAttas © 27
Looking Inside States
Simple State: a state that contains no
substructure.
Composite State: a state that has other
states nested within it, in order to
represent some internal behavior.
Reem AlAttas © 28
A Simple Telephone State Chart
Diagram
Reem AlAttas © 29
A State Chart Diagram of the
Composite State Active
Default
Sub-
state
Reem AlAttas © 30
No Default Sub-state
Reem AlAttas © 31
Topic Road Map
Capturing more complex interactions
Design issues
An introduction to state machines
Variation of events and actions
 Packages
Reem AlAttas © 32
Package
A general purpose mechanism for
organizing model elements into groups.
Ex. A package allows you to gather
together classes that share some common
feature or behavior, such as order
processing or stock control.
Reem AlAttas © 33
Why to Partition a S/W?
Manage size and complexity.
Information hiding.
Logical decomposition.
Reem AlAttas © 34
Typical MIS
Reem AlAttas © 35
Nested Packages
Reem AlAttas © 36
Packages Present Architecture
 Three-tiered architecture advantages:
 Parallel development.
 Reusability.
 Distribution.
Reem AlAttas © 37
Subsystems
A subsystem has two sets of elements:
 Specification: Uses cases.
 Realization: Classes.
Reem AlAttas © 38
… Subsystems
Or
<<subsystem>>
Operations
TMA4 – Q5
Thank You!

States and Activities

  • 1.
    Arab Open University 2nd Semester,2006-2007 M301 Unit 4.5 States and Activities reem.attas@arabou.org.sa
  • 2.
    Reem AlAttas ©2 Topic Road Map  Capturing more complex interactions Design issues An introduction to state machines Variation of events and actions Packages
  • 3.
  • 4.
    Reem AlAttas ©4 If Statement Guard
  • 5.
    Reem AlAttas ©5 If .. Else Statement Mutually Exclusive Branch
  • 6.
    Iterative Message Sendsin Sequence Diagrams
  • 7.
    Reem AlAttas ©7 For Loop
  • 8.
    Reem AlAttas ©8 Topic Road Map Capturing more complex interactions  Design issues An introduction to state machines Variation of events and actions Packages
  • 9.
    Reem AlAttas ©9 Defensive Programming Pre-conditions should always be checked. Disadvantage: conditions are repeatedly checked in different places.
  • 10.
    Reem AlAttas ©10 Strategies for Implementing Use Cases One Central Class. Actor Class. Use Cases as Classes.
  • 11.
    Reem AlAttas ©11 Topic Road Map Capturing more complex interactions Design issues  An introduction to state machines Variation of events and actions Packages
  • 12.
    Reem AlAttas ©12 The Essentials of State Machines  An event is an occurrence of a phenomenon at a certain moment in time and in a certain place.  Each state represents a particular period for which a given set of conditions applies.  Change takes place through transitions from one state to another. Transitions are said to be fired or triggered by events.
  • 13.
    Reem AlAttas ©13 Two Simple States for a Room Object Initial State Event Transition
  • 14.
    Reem AlAttas ©14 … The Essentials of State Machines  An event when it occurs, has consequences. One consequence is a change of state. Other consequences are recorded in the action part of the label on the transition.  That is, instead of labeling a transition just with a simple name, we also record the actions (consequences) that result from the occurrence of the event.
  • 15.
    Reem AlAttas ©15 Check In Sequence Diagram
  • 16.
    Reem AlAttas ©16 Adding Detail to a State Machine for a Room Object Event Action ; aGuest.setRoom (self)
  • 17.
    Reem AlAttas ©17 A Simple State Machine for the Hotel Class Self Transition
  • 18.
    Reem AlAttas ©18 Self Transition  Originates in one state and returns to the same state.  If the same event is used on more than one transition, you must make sure that no more than one guard can evaluate to true. At most, you want just one transition to fire in such situations.
  • 19.
    Reem AlAttas ©19 Entry and Exit Events An entry event happens every time an object enters a state. An exit event happens every time an object leaves a state.
  • 20.
    Reem AlAttas ©20 … Entry and Exit Events
  • 21.
    Reem AlAttas ©21 Internal Transition A special transition that does not involve a change of state. In contrast to a self-transition, an internal transition does not cause the execution of any entry or exit actions.
  • 22.
    Reem AlAttas ©22 … Internal Transition  An internal transition may be used to handle an interrupt where you want some action to take place that does not affect the current state.  Internal transitions are written inside the state to which they refer.
  • 23.
    Reem AlAttas ©23 Final State  A state chart diagram shows no more than one initial state but there can be zero, one or more final states.  Initial and final states signify the creation and destruction of an object.
  • 24.
    Reem AlAttas ©24 Topic Road Map Capturing more complex interactions Design issues An introduction to state machines  Variation of events and actions Packages
  • 25.
    Reem AlAttas ©25 Other Kinds of Events External Vs. Internal Events. Synchronous Vs. Asynchronous Actions. UML defined 4 types of events:  Call Events.  Signal Events.  Change Events.  Time Events.
  • 26.
    Reem AlAttas ©26 Time Event
  • 27.
    Reem AlAttas ©27 Looking Inside States Simple State: a state that contains no substructure. Composite State: a state that has other states nested within it, in order to represent some internal behavior.
  • 28.
    Reem AlAttas ©28 A Simple Telephone State Chart Diagram
  • 29.
    Reem AlAttas ©29 A State Chart Diagram of the Composite State Active Default Sub- state
  • 30.
    Reem AlAttas ©30 No Default Sub-state
  • 31.
    Reem AlAttas ©31 Topic Road Map Capturing more complex interactions Design issues An introduction to state machines Variation of events and actions  Packages
  • 32.
    Reem AlAttas ©32 Package A general purpose mechanism for organizing model elements into groups. Ex. A package allows you to gather together classes that share some common feature or behavior, such as order processing or stock control.
  • 33.
    Reem AlAttas ©33 Why to Partition a S/W? Manage size and complexity. Information hiding. Logical decomposition.
  • 34.
    Reem AlAttas ©34 Typical MIS
  • 35.
    Reem AlAttas ©35 Nested Packages
  • 36.
    Reem AlAttas ©36 Packages Present Architecture  Three-tiered architecture advantages:  Parallel development.  Reusability.  Distribution.
  • 37.
    Reem AlAttas ©37 Subsystems A subsystem has two sets of elements:  Specification: Uses cases.  Realization: Classes.
  • 38.
    Reem AlAttas ©38 … Subsystems Or <<subsystem>> Operations
  • 39.
  • 40.

Editor's Notes

  • #26 Synchronous: occurring at regular intervals.