Você está na página 1de 10

State Charts

for detailed modeling


Larman, chapter 29
Object-Oriented Software Engineering

Introduction to State
Diagrams

Interaction diagrams are very good for communication

But they are not part of the constructive core

Constructive core means that part from which an actual implementation


could be generated

The constructive core of the UML is

between clients and designers


between designers and other designers
between designers and implementors

class diagrams (for the static part)


state diagrams (for the dynamic part)

State diagrams can describe very complex dynamic behavior

State chart Diagrams


A State chart diagram shows the lifecycle of an object
A state is a condition of an object for a particular time
An event causes a transition from one state to another state
Here is a State chart for a Phone Line object:
state
initial State

event
transition

State charts in UML:


States in ovals, Transitions as arrows

Transitions labels have three


optional parts:
Event [Guard] / Action

Find one of each


Item Received is an event,
/get first item is an action,
[Not all items checked] is a
guard

State may also label activities,


e.g., do/check item

Superstates (nested states)

Example shows a
super-state of
three states

When one state is


complex, you can
include sub-states
in it.

drawn as
nested
rounded
rectangles
within the
larger state

Concurrency in state diagrams

Dashed line indicates that an order is in two different


states, e.g. Checking & Authorizing
When order leaves concurrent states, its in a single
state: Canceled, Delivered or Rejected

State Diagram for Seminar


Registration
event

Setup

action, taken during


transition

AddParticipant / Set count = 0

do/initialize seminar

Available
do/initialize seminar

cancel
seminar

[ count = 20 ]
cancel seminar
guard
Canceled

cancel seminar

do/refund payments

multiple
exits

Full
do/finalize seminar

aktivity, carried out


while in that state

Exercise 1 - Claims

A third party claim arises from an incident that has occurred. The
claim must be reported to the claims office within the statutory
period to be valid. When the claim is reported, the incident is
preferably verified by a member of staff who was present at the
time. The claim is recorded and evaluated. If it is a trivial claim,
the claims assessor checks the claimant for previous claims and,
if there are no or 1 previous claims then a payment is made and
the claim is settled. If there are previous claims, the claimant will
be referred to the courts. More serious claims may await expert
evidence and several different court hearings. At any stage, the
claim may be dropped, or a payment made without admitting
liability. If the claimant is a minor, the claim must remain on the
books until the claimant is over 21. If a claim is settled by a court,
it may be appealed. During this time, the claim remains open.
Draw a state diagram for a claim.

Solution

Claim reported

Claim reported
accident not verified

Claim
Dropped

Accident verified
Claim reported and
Accident verified

Refer to expert
Awaiting expert
report
Report submitted

Refer to underwriter
Reject

SettlementDisputed

Settled

Passed on to
underwriter

TimePassedUndisputed
Claim rejected
TimePassedUndisputed

DeleteClaim

Você também pode gostar