With UML Statechart Diagrams

  Specification and Analysis of Information Systems Specifying State-based Behavior With UML Statechart Diagrams

  Munawar an_moenawar@yahoo.com

Outline

  • Introduction to Statecharts • Statechart building blocks
    • – States – Transitions

  • Advanced Characteristics
    • – Composite States – Parallel States

Modeling Process in UML Phase Actions Outcome

  Initiation

  Raising a business need Business documents

  Requirements

  Interviewing stakeholders, exploring the system environment Organized documentation

  Analyze the engineering aspect of the system, building system concepts Formal specification

Specification

  Define architecture, components, data types, algorithms Formal Specification

Design

  Implementation

  Program, build, unit-testing, integrate, documentation Testable system

  Testing & Integration

  Integrate all components, verification, validation, installation, guidance Testing results, Working sys

  Bug fixes, modifications, adaptation System versions

Maintenance

What’s Missing in Behavior Modeling?

  p : Product : ShooppingCart customer display() getPrice() addProduct (p) checkout ()

  In Sequence diagram, we do not really know how the state of the shopping cart changes.

Modeling States

  How can we model the state of the shopping • cart?

Depends on: •

  • – Object state (e.g. created, destroyed)
  • – Variable assignment
  • – Relation status (i.e. number of items)
  • – Operating methods & processes
  • – History

The Automata

  A machine whose output behavior is not only a • direct consequence of the current input, but of some past history of its inputs.

Characterized by an internal state which represents • this past experience

  If the phone is ON, then clicking will turn it off If the phone is OFF, then clicking will turn it on

Automata – Mathematical Foundations

  , ,S An Automata is a 5-tuple: ⟨S,

  • S is a set of states is an alphabet - finite set of symbols

  Σ δ

  • S

  Σ

  δ is the transition function: δ – : S × Σ →

  • S is an initial state

  Given a state and

  click

  an input, the automata jumps to click a new state

  S on off

Many uses:

  • – Stochastic processes (x, y & z are probabilities)
  • – Formal and natural languages (x, y & z are characters)
  • – Complex systems (x, y & z are…)

Automata Modeling with Statecharts

  • A Statechart augments deterministic automata,

  making them suitable for specifying behavior of complex systems, using:

  • – Visual formalism
  • – Rich alphabet model
  • – State Modularity – Parallel behavior
    • Developed by David Harel (Weizman Inst.)

Outline

  • Introduction to Statecharts • Statechart building blocks
    • – States – Transitions

  • Advanced Characteristics
    • – Composite States – Parallel States

States & Classes Class view

State view

  State created

  Transition Order status: {created, sent, in gathering received} hasProblems : boolean gatherItems() sent updateInventory() sendOrder() received(customer) sendReciept() in problem is received

Activities

  • When holding the state, the

  component can perform activities.

  • – Can be continuous, taking a specific, or unbounded, time
  • – Activities within a state are sequential
  • – Activities can be interrupted
    • There are special types of

  activities: enter, exit and event classified activities in gathering do: gatherItems() do: updateInventory() created enter: set hasProblems to false do: init gathering list exit: clean log file

Transitions x

  y event [guard] | action The event that triggers the transition

Conditions that

must be met for the transition to take place The action that takes place when the transition is taken

Events

  • General Events
    • – Method calls : received(customer)
    • – Event signals: inventoryReady

  • Time event
    • – interval expiry;

  tm(3 days), tm(1000 ms)

  • – calendar/clock time; when(11:50)
    • Change Event:

  • – Change in value of some entity;

  false(hasProblems) true(hasProblems) created sent in gathering is received inventoryReady tm(3 days) false(hasProblems) received() in problem

Guards (Conditions)

  gatheringFinished [all items were gathered] sent in gathering in problem gatheringFinished [items are not found] • Boolean expressions.

  • Evaluated when the transition is triggered
  • Types of guards:
    • – Simple predicate: [hasProblems], [x > 0]
    • – Combined predicates:

  ¬hasProblems ∨ (hasProblems ∧ order.sum < 100] [

  • – Guards on activities: [active(gatherItems)]
  • – State related (we’ll get back to it later)

Guards - Example

  bid [value < 100] bid [value >= 200]

Happy Selling

  bid [(value >= 100) AND (value < 200)] Unhappy

Static Conditional Branching

  • A graphical shortcut for convenient rendering of

  decision trees [(value >= 100) & (value < 200)] [value >= 200]

  [value < 100] Selling Unhappy

  Happy bid

Empty Transitions

  • A transition can have any combination (including

  none) of the events, guards and actions

  • • When a transition does not have an event, it is taken

  after all the activities were ended Cleaning do: put water do: put soap do: wash soap do: drain doing nothing Employee rest[break] work

  Working do: shovel

  Empty Transition work

Guards and Events

  What’s the difference between the two machines? • true(C) E1 S1 S2

  S3 What happens if C changes to True before E1?

Actions

  An executable atomic computation • Types of actions •

  • – Variable assignment:

  received() | status := received is received sent

  • – Throwing a signal:

  received() | throw(InventoryUpdate) is received sent

  • – Start, or stop activities (and concatenation of actions):

  

| start(sendBill); stop(delivery); x := x+1

sent is received

Transitions - advanced

  Self-transitions: Transitions can be directed to the • same state: / c=0

  

S2

E1 / c:=c+1 Un-deterministic states – when two transitions are • taken in the same time, one of will be taken in an un-deterministic fashion:

How does a Washing Machine Works?

  On / Off button. Start button • (No stop button.) • Feedback is given on the • current stage (soaking, rinsing, draining, drying)

  • • Three plans:

    • – Regular – Delicate (no soaking)
    • – Super delicate (no soaking, no

      drying)

  Off can be clicked only before • starting, or after finishing

  22

Outline

  • Introduction to Statecharts • Statechart building blocks
    • – States – Transitions

  • Advanced Characteristics
    • – Composite States – Parallel States

State Explosion: An Example off

  What is the off click(power) click(power) button can be idle clicked at any time? Tm(10 mins) | light(off)

  click(start) [plan=regular] soak click(start) [plan=delicate Do: light(soak)

  What if we want to show or super delicate] Do: pump(in) how many minutes left to tm(30 mins) Tm(5 mins) [plan=super delicate] | light(off) the end of the cycle? Do: stir() Do: pump(out) Do: stir() Do: light(rinse) Do: light(drain) Do: light(dry) rinse drain dry tm(30 mins) [plan=not super tm(5 mins) delicate]

  What if we want to come back to the same state we left?

  Abstraction in Statechart Finding Common Behavior Separating Independent Regions Composite States Parallel States

The State Explosion Problem

  Class Class Class v : {t, f} v : {t, f} v : {t, f}

  1

  1

  1

  v : {t, f} v : {t, f} v : {t, f}

  2

  2

  2

  v : {t, f} v : {t, f} v : {t, f}

  3

  3 3 ... ...

  ...

  ...

  • Let
    • – n: Num of Classes – m: Num of variables (assume equals among classes)

  (nm)

  • Number of possible states =

  2 • And...

  • – What if the state space of each variable > 2
  • – What about association between objects?

  27

  28 History

  deep and shallow Shift ended | clh()

  Stop pause

  Diagnosing return

  H Diagnostic2 Diagnostic1 return-full setup Find a vein H* clh() – clears Check blood

  Draw Blood pressure the history

Completion Transitions

  • Triggered by a completion event
    • – generated automatically when an immediately nested state machine terminates

  Committing Phase1 Phase2

  Commit Done completion transition (no trigger)

Triggering Rules

  • Two or more transitions may have the same
    • – inner transition takes precedence
    • – if no transition is triggered, event is discarded

  LampFlashing off/ FlashOff FlashOn

  event trigger

  on/ on/

Order of Actions: Complex Case

  Same approach as for the simple case • S1

S2

  exit:exS1 entry:enS2 | initS2

  E/actE S11

S21

  exit:exS11 entry:enS21

Actions execution sequence:

  exS11 exS1 actE enS2 initS2 enS21 Ö Ö Ö Ö Ö

Parallel States

  Sometimes, some aspect of an entity are • independent of other aspects Martial employee single

  Staff Member married Manager divorced

Parallel States Annotation

Combine multiple simultaneous descriptions •

  Martial employee single

  Staff Member married Martial employee Manager single divorced Staff Member married Manager divorced

  35 States

  “Flat” and Parallel Machines

  parallel

  Every machine can be transformed into a sequential • machine: A D

  μ

  E

Use of B

  δ

F Orthogonal

  γ α β

  (in G)

Regions

  α

  G C

  μ δ

  γ

No Use of

  α α

  β α

Orthogonal

  γ

Regions C,G

  α μ

  δ

Transition Forks and Joins

  For transitions into/out of orthogonal regions: • shipping Processing Sent Confirmed

  [ok]

  Credit Card Receipt Sent verification fork

  Join

  [not ok]

  charging

  In problem

Summary

  9 Statechart:

  • – State-based modeling
  • – Based on Automatas

  9 Statechart building blocks

  • – States – Transitions

  9 Advanced Characteristics

  • – Composite States – Parallel States

Dokumen yang terkait

Analisis Efektivitas dan Kontribusi Penagihan Tunggakan Pajak Dengan Penerbitan Surat Teguran dan Surat Paksa Terhadap Penerimaan Pajak (Studi Kasus Pada KPP Pratama Jember) Effectiveness and Contribution Analysis of Tax Arrears Collection With The Issuan

1 47 7

Hubungan Sumber Informasi Dengan Perilaku Seksual Berisiko Remaja Di Kecamatan Sumbersari Kabupaten Jember (The Relationship Between Source of Information With Risk Sexual Behavior On Adolescent In District Sumbersari In Jember Regency)

0 34 8

Pengaruh Metode Pembelajaran Learning Starts With A Question (LSQ) Terhadap Hasil Belajar Mata Pelajaran IPS Kelas IV Di MIN 15 Bintaro

4 49 215

Kampanye Komersial/Promosi Chocodot (Chocolate With Dodol Garut)

5 98 77

Penerapan UML Based Web Engineering Pada Pengembangan Website Penjualan Online (E-Commerce)

0 11 7

HUBUNGAN DUKUNGAN KELUARGA DENGAN Quality of Life (QOL) PADA KEJADIAN STROKE Relationship Of Family Support With Quality of Life (QOL) Stroke Occurrence

0 1 7

TOTAL ASAM, TOTAL YEAST, DAN PROFIL PROTEIN KEFIR SUSU KAMBING DENGAN PENAMBAHAN JENIS DAN KONSENTRASI GULA YANG BERBEDA Total Acid, Total Yeast, Protein and Profile Kefir Goat Milk, With Addition Type and Concentration of Sugar in Different Level

0 0 10

Mobile Multiplayer Game Interaction With XMPP

0 0 26

Fuel Use Efficiency on Motor Vehicle With Do Shortest Path Routing Using Hopfield Neural Networks at Purwokerto Area

0 0 7

View of Stick Figure and Think, Talk And Write: Integrating Media With Teaching Strategy For A Better Writing Competence

0 0 5