Software engineering methods Requirements - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Software engineering methods Requirements

Description:

Software Engineering Methods State Diagrams With additions by Zvika Gutterman and Adam Carmi Written By Zvi Avidor State Diagram A Type of a finite state machine. – PowerPoint PPT presentation

Number of Views:101
Avg rating:3.0/5.0
Slides: 20
Provided by: Zvi85
Category:

less

Transcript and Presenter's Notes

Title: Software engineering methods Requirements


1
Software Engineering Methods
State Diagrams
With additions by Zvika Gutterman and Adam Carmi
Written By
Zvi Avidor
2
State Diagram
  • A Type of a finite state machine.
  • Best for modeling one class whose behavior
    depends on its state.
  • Models the states of an object and how it moves
    from state to state for its entire lifetime.
  • A class should have its own state diagram if it
    has interesting dynamic behavior.
  • Controllers
  • Devices (e.g. modem dialing, sending,
    receiving)
  • Objects that change state or role (e.g. a Book
    may be borrowed, overdue or in Library)

3
Example
Starting Point
Event
State
Transition
4
Events
  • An event is something that happens and that may
    cause some action.
  • Stimuli that affects an object
  • Primary means of communication between objects.
  • Drive objects from one state to another.
  • Corresponds to
  • Operations
  • Modification of attribute values.
  • Passage of a designated period of time.
  • The source of the event is not specified.

5
States
All compartments are optional
6
State Variables
  • The composite values of all attributes and links
    held by an object represent the objects
    identity.
  • Ignore attributes that do not affect the objects
    behavior.
  • No two distinct states of a single object can
    have identical responses to all events.
  • Lump together sets of values that have the same
    response to events.
  • Temporary attributes (that trigger events) may
    also be represented.

7
Activities Actions
  • Activity
  • Takes time
  • Associated only with states.
  • May be interrupted by some event.
  • Can often be modeled as a nested state diagram.
  • Example
  • Downloading a file.

8
Activities Actions (cont.)
  • Action
  • Have short duration
  • Associated with states and transitions
  • Atomic
  • Examples
  • Beep
  • Display a menu
  • set a flag
  • Sending a message (firing an event)

9
Activities Actions (cont.)
  • Actions can be spawned on entry and exit to
    states.
  • entry/ entry-action(s)
  • exit/ exit-action(s)
  • Activities may be indicated
  • do/ activity(ies)
  • Internal events may be indicated (instead of self
    directed transitions)
  • internal-event/ action(s)

10
Activities Actions (cont.)
  • Example

Actions/Activities should be specified as
operation signatures whenever possible
11
Transitions
  • A transition is a relationship between a source
    state and a target state indicating that an
    object having the source state will change its
    state to the target state, when a specified set
    of events occur and/or a set of conditions are
    satisfied.
  • A self transition is a transition whose source
    and target states are the same.
  • Actions may be attached to transitions.
  • Transitions from the same state must be mutually
    exclusive. Otherwise, objects state is undefined.

12
Transitions (cont.)
  • Represented as a directed edge between two
    states.
  • Transition (general) syntax
  • event (attributes) condition(s) / action(s)
    send-clause
  • All components are optional.
  • Transition semantics
  • IF the event occurs AND all specified conditions
    are true THEN spawn the specified actions and
    change object state to the target state.
  • If the triggering event is not specified, the
    transition will be attempted when all the state
    activities complete.

13
Transitions (cont.)
  • A send-clause is used to send a message (event)
    to other objects (or to the same object).
  • Syntax destination-expression .
    destination-event-name (arguments)
  • Example

fall asleep() myFriends.tell("be quiet")
awake
asleep
14
Examples
It would be better to add the guard condition
!isHungry
15
Sub-states
  • A sub-state is a state that is contained in
    another state (a composite state).
  • Sub-states may be nested to any level.
  • Example

16
Transitions and sub-states
  • If a transition is to a sub-state the sub-state
    is entered after any entry action for the
    enclosing composite state is executed.
  • If a transition is from a sub-state within the
    composing state, any exit action for the
    sub-state is executed followed by any exit action
    for the enclosing composite state.
  • A transition from the composite state may occur
    from any of the sub-states and takes precedence
    over any of the transitions of the current
    sub-state.

17
Sub-states (cont.)
  • or sub-state
  • Sub-states can occur only one at the time.

Driving
Forward
Backward
18
Sub-states (cont.)
  • and sub-states
  • Some of the sub-states can exist simultaneously

Driving
Forward
Backward
Low speed
High speed
19
History indicator
  • Used to memorize internal states
  • usually used in cases we want to return to an
    interrupted state.

Cook
Prepare ingredients
Prepare kitchen
Prepare food
H
Answer Phone
Write a Comment
User Comments (0)
About PowerShow.com