Title: A Student Guide to ObjectOriented Development
1A Student Guide to Object-Oriented Development
2State diagram
A state diagram shows the effects of all use
cases on one class
3State diagram
- Increasingly used to model ways a system can
respond to external events - All objects of the class (the individual
customers or products) have the same set of
responses, but each responds differently
depending on the state it is in.
4State Diagram
- Describes the behaviour of a single class
illustrating how its objects behave during their
lifetimes ( all uses cases ) - Model the order that events affect an object
- The bike must be assigned a number before it can
be rented - In most systems only a few of the classes are
complicated enough to merit a state diagram. - State diagrams are also referred to as state
charts and state transition diagrams
5States and Events
- State - The situation an object it is in while
satisfying some condition (such as a bank account
having some money) or waiting for an event (such
as someone trying to withdraw or deposit money).
- State has duration.
- Event - An event is something that happens which
has significance for the system and affects an
object of at least one of the systems classes. - We can tell if an object is in a particular state
by looking at the values of some of its
attributes and its links to other objects. - Events are instantaneous.
6The state of an object
- For example, if a Bank Account object is in
credit the value of the balance attribute will be
a positive amount or zero - but if it is overdrawn the value of balance will
be negative. - In the Wheels case study, we can tell if a bike
is rented out because there will be a link from
the Bike object to an active Hire object.
7state
start state
stop state
transition from one state to another
self-transition (no change of state)
event guard / action
transition label (each of the three parts is
optional)
8State diagram for a bank account class
stop state
Self transition
Guard
state diagram for a bank account class
Event fires a transition
Start state
9Event/guard/action
superstate
10State diagrams key words
- after used to show an event taking place
after a specified time period e.g. after 6
months / delete - when event takes place when a condition is
satisfied e.g. when all items in stock / fill
order
11State diagrams entry and exit events
offHook entry / start dialling tone exit / stop
dialling tone do / emit dialling tone
Keyword do behaviour that lasts for the
duration of a state is called an activity, it is
modelled using the keyword do