L7 State Machines Flashcards

1
Q

What is a State Machine Diagram?

A

It models the behaviour of a thing, specifying the sequence of states that it goes through during its lifetime in response to events.
‘Thing’ could be system, subsystem or class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do State Machines/diagrams/charts model?

A

Dynamic behaviour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain what a State Machine Diagrams is

A
  1. Models what could happen when an object receives a message
  2. Include events that lead to object changing state
  3. The same objects can behave differently depending on the states and events.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a “State”

A

Condition object stays in for some time, during which it behaves in the same way. But may respond differently to the same trigger (event) in different states.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a “Transition”

A

From one state to the next; may have a trigger, a guard and an effect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a “Trigger”

A
  • External, instantaneous stimulus
  • A signal, an event, a change in some condition, or the passage of time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a “Guard”

A

A condition which must be true in order for the trigger to cause the transition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an “Event”

A

An action that occurs as a result of the transition.
Actions can be associated with the transition itself, with entry to or exit from a state, or can occur continually during a state (“do” activity)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

LABEL ON TRANSITION IS

A

trigger (list of input data) [guard] / effect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the three types of Event Types

A
  1. Signal event (Receipt of a signal e.g., rightmousedown, sendSMS(message)
  2. Call Event (Operation call, e.g., occupy(user,lectureHall), register(exam)
  3. Time Event (Time-based state transition)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the Composite States

A
  • State machines can be nested, so that we can hide a submachine/substate at some level of abstraction.
    • What appears as a single state at one level can be viewed in more detail -we can “zoom in”.
  • Substates can be shown in place, or hidden with use of composite icon.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the Concurrent States?

A
  • If a composite state machine has two or more regions, their submachines operate concurrently.
  • State of the object is a pair (or tuple) of substrates
  • Entry and exit can be synchronized by fork and join
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

State Notation

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Modelling the state of a bank account….

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Modelling the state of a lecture hall….

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Event Types

A

● Signal event
Receipt of a signal e.g., rightmousedown, sendSMS(message)
● Call event
Operation call, e.g., occupy(user,lectureHall), register(exam)
● Time event
Time-based state transition
- Relative: based on the time of the occurrence of the event, e.g., after(5 seconds)
- Absolute, e.g., when(time==16:00), when(date==20150101)

17
Q

Changing from one state to another….

18
Q

Example: login part of a system

19
Q

Building a State Diagram

A

Britton and Dokes recommends:
1. Identify the events that affect an object
2. Identify the possible different states, including start and stop states
3. Check whether events are conditional
4. Identify any actions the object performs in response to an event
5. Begin the diagram from the start state
6. Build the diagram systematically through events and states
7. Check for super states/composite states

20
Q

Building an example State Diagram

A

A Human Resources system has the following requirements:
- A job application is created when an application form is received and details recorded.
- The application is read by a manager and either shortlisted or rejected
- If rejected the JA is filed for 6 months then discarded
- If shortlisted, interview details are sent out and the interview usually confirmed by the candidate
- After interview the applicant may not be successful and a rejection letter is sent and the JA filed for 6 months then discarded
- If the applicant is offered the job an offer letter is sent out
- If the applicant declines the JA is filed for 6 months then discarded
- If the offer is accepted other procedures take over the processing
- The applicant may withdraw at any point